how to do in place reversal of a linked list(singly or
doubly)?

Answer Posted / ashish gupta

rev()
{
struct node *a1,*a2,*a3;
if(start->next==NULL) /*Only one element exists*/
return;
a1=start;
a2=a1->next;
a3=a2->next;
a1->next=NULL;
a2->next=a1;
while(a3!=NULL)
{
a1=a2;
a2=a3;
a3=a3->next;
a2->next=a1;
}
start=a2;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is c++ used for today?

755


Difference between pass by reference and pass by value?

740


What is the value of uninitialized variable in c?

666


The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this

3108


Why static is used in c?

719






What is structure in c language?

717


How can I swap two values without using a temporary?

702


The difference between printf and fprintf is ?

803


What is chain pointer in c?

692


Explain what are global variables and explain how do you declare them?

739


How can I remove the trailing spaces from a string?

698


What are the application of void data type in c?

883


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

1695


What header files do I need in order to define the standard library functions I use?

628


What is structure of c program?

693