How would you sort a linked list?



How would you sort a linked list?..

Answer / prakashdasari

node *ptr1,*ptr2,*ptr3;
ptr1=start;
ptr2=ptr1->next;
ptr3=ptr2->next;
ptr1->next=NULL;
ptr2->next=ptr1;
while(ptr3!=NULL)
{
ptr1=ptr2;
ptr2=ptr3;
ptr3=ptr3->next;
ptr2->next=ptr1;
}
start = ptr2;

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Interview Questions

What is function definition in c?

0 Answers  


Write a c program to Find the name that you entered is male name or female name? Such as Sunjay is name of male and Payal is name of female

5 Answers   Infosys, Luminous,


Write a code of a general series where the next element is the sum of last k terms.

0 Answers   Aspiring Minds,


What is the difference between #include and #include 'file' ?

0 Answers  


What does %c mean in c?

0 Answers  


question-how to run a c programme.

6 Answers  


how to connect oracle in C/C++.

3 Answers   TCS, Wipro,


What are all different types of pointers in c?

0 Answers  


char *p="name"; printf(p);

1 Answers  


progrem to generate the following series 1 12 123 1234 12345

6 Answers   HCL, Wipro,


What is volatile, register definition in C

0 Answers   Cognizant,


how to reverse string "Hello World" by using pointers only. Without any temp var

1 Answers  


Categories