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 the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

847


What does c value mean?

852


Can we assign string to char pointer?

797


what are non standard function in c

1636


Write a program to generate random numbers in c?

845


Which is better oop or procedural?

809


Why is this loop always executing once?

794


How can I automatically locate a programs configuration files in the same directory as the executable?

840


What is the use of function in c?

912


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

852


pierrot's divisor program using c or c++ code

1954


Explain how can I convert a string to a number?

834


hi any body pls give me company name interview conduct "c" language only

1879


Describe wild pointers in c?

834


What is the difference between functions abs() and fabs()?

856