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 meaning of course?
Mention a package that is used for linked list class in java.
What is java used for on a computer?
What is the importance of static variable?
Is java a super set of javascript?
Can you use this() and super() both in a constructor?
Why do we declare a class static?
Can a method be static?
What is keyword in oop?
What is the purpose of sizeof operator?
Explain the use of shift operator in java. Can you give some examples?
How do you create a null object?
Tell us something about an iterator.
How many functional interfaces does java 8 have?
What is a bubble sort in java?