How would you sort a linked list?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

how is the examination pattern?

1598


What is #include called?

570


What does 2n 4c mean?

721


What are the data types present in c?

629


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

589






How do you generate random numbers in C?

660


How can I discover how many arguments a function was actually called with?

636


Write a program for finding factorial of a number.

636


What is the use of a conditional inclusion statement in C?

603


What is bubble sort in c?

640


What are the two types of functions in c?

567


why return type of main is not necessary in linux

1707


What is sizeof array?

613


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

637


How can I read a binary data file properly?

635