Answer Posted / kaustubh
I'll give the algo here.You may write it in a programming
language of your choice.
Iterative Algo:
node *Reverse(node *head)
{
node *p,*q,*r;
p=head;q=r=NULL;
while(p!=NULL)
{
q=p;
p=p->next;
q->next=r;
r=q;
}
head=q;
return head;
}
Recursive algo:
From main call: Reverse(node *head,NULL)
reverse(node *p,node *q)
{
if(p->next!=NULL)
reverse(p->next,p)
else
{
p->next=q;
return
}
}
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
what is anonymous class in java?
What are the different types of multitasking?
What are the differences between abstract class and interface?
What is java Applet?
How can you share data between two thread in Java?
Is space a char?
What is a byte string?
What are alternatives to java serialization?
What is the difference between hashmap and hashtable? What is an interface?
What do you understand by access specifiers in Java?
Explain different forms of polymorphism?
What is a nonetype?
What is the purpose of the finally clause of a try-catch-finally statement in java programming?
How to declare objects of a class ?
Can constructor return value?