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

Is java as fast as c++?

800


What is c++ course?

786


What is pointer to array in c++?

809


What is the difference between while and do while loop?

819


Differentiate between declaration and definition.

776


What is istream c++?

824


What is long in c++?

968


What are the operators in c++?

850


How is data hiding achieved in c++?

781


What is command line arguments in C++? What are its uses? Where we have to use this?

851


What is #include iostream h in c++?

839


What are c++ manipulators?

808


What is dev c++ used for?

775


Is dev c++ free?

793


If a base class is an adt, and it has three pure virtual functions, how many of these functions must be overridden in its derived classes?

802