How many pointers are required to reverse a link list?

Answer Posted / vivek

# 3 using 2 pointer:
void reverse(node* head_in_out)
{
if(head_in_out)
{
node* aCurr = head_in_out;
node* aNext = NULL;
while (aCurr)
{
head_in_out = aCurr->next;
aCurr->next = aNext;
aNext = aCurr;
aCurr = head_in_out;
}
head_in_out = aNext; // Bug in above 3rd answer.
}

}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I exit turbo c++?

576


Can constructor be static in c++?

632


What is a storage class?

635


What are the various oops concepts in c++?

588


How many static variables are created if you put one static member into a template class definition?

558






Why was c++ made?

645


What are formatting flags in ios class?

602


Difference between declaration and definition of a variable.

581


What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0

576


What's the most powerful programming language?

580


Define vptr.

585


Why is c++ so fast?

524


What is function declaration in c++ with example?

538


Briefly describe a B+ tree. What is bulk loading in it?

789


Difference between strdup and strcpy?

642