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
How many digits can a float hold?
What is equlas() and hashcode() contract in java? Where does it used?
Give any two differences between C++ and java.
What is the difference between jdk and jre?
How to change the priority of thread or how to set the priority of thread?
What is a programming object?
What is a bubble sort in java?
What is method overloading with type promotion?
What is the static field modifier?
What are exception handling keywords in java?
How dead lock situation occurs in java and how you can identify it?
Can we store variables in local blocks?
What is purpose of keyword void?
What package is math in java?
Can we override protected method in java?