How many pointers are required to reverse a link list?

Answer Posted / vivek

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;
}
}

}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Specify some guidelines that should be followed while overloading operators?

718


What is ios :: in in c++?

736


What is the purpose of ios::basefield in the following statement?

889


Explain how would you handle a situation where you cannot call the destructor of a local explicitly?

623


What does the linker do?

690






What is difference between c++ and c ++ 14?

671


Is eclipse good for c++?

623


write a programme to get a character and thier ASCII value

2674


What is an iterator class in c++?

697


Differentiate between declaration and definition.

680


If dog is a friend of boy, is boy a friend of dog?

657


Is c++ platform dependent?

727


What are advantages of using friend classes?

734


What are the two types of polymorphism?

682


What are member functions used in c++?

658