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 the constructor?
Is it necessary that each try block must be followed by a catch block?
What is the disadvantage of synchronization?
What is the use of private static?
Are constructors methods?
What is the arraylist in java?
What is the difference between a method and a procedure?
What is overloading and overriding in java?
What is the meaning of I ++ in java?
Define jit compiler?
What is method in java ?
What is jrmp?
What is a condition in java?
Is string a class?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?