Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

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

Why c++ does not have finally?

365


What is a Default constructor?

592


What type of question are asked in GE code writing test based on c++ data structures and pointers?

3298


What is iterator in c++?

380


How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?

367






What is the use of class in c++?

367


What is microsoft c++ redistributable?

390


Is c++ a dying language?

349


What methods can be overridden in java?

457


what is upcasting in C++?

433


When the constructor of a base class calls a virtual function, why doesn't the override function of the derived class gets called?

362


Evaulate: 22%5 a) 2 b) 4 c) 0

432


In a function declaration, what does extern mean?

421


Explain the scope of resolution operator.

381


How can I learn c++ easily?

366