how to swap two numbers in a linked list without exchanging
the data but only the links?
Answers were Sorted based on User's Feedback
Answer / sha
let q=20,r=10 and p be a node previous to q
sequence is p-q-r
temp is pointer of link list.
then
temp=p->next;
p->next=temp->next;
p->next->next=temp;
and temp next can be conected to p->next->next->next if
there is any
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / pavny
Suppose List contains 3 no. 10, 20, 30
try to exchange 10 and 20.
head points to 10.
temp = head;
head = head -> next;
temp -> next = head - next;
head -> next = temp;
I think it works..
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / siva
head points 20
head=head->link;
link->next;
link->head=head->next
| Is This Answer Correct ? | 1 Yes | 3 No |
Can we use stl in coding interviews?
Give the output of the following program main() {int ret; ret=fork();ret=fork();ret=fork();ret=fork(); if(!ret) printf("sun"); else printf("solaris");
What are the different types of stl containers?
i want a road rash 3d game code if some one know please help me
Is stl open source?
how to swap two numbers in a linked list without exchanging the data but only the links?
What is stl language?
write a program that will accept a number and print.its equivalent in words the maximum input number is 9999
What is meant by stl in c++?
What is a standard template library (stl)? What are the various types of stl containers?
I am doing my BS.c MATHS CAN I ABLE TO JOIN IN NIIT?
Describe the elements of Microsoft Word screen. Write down steps for creating, saving, retrieving, editing and printing a document.