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
How do I exit turbo c++?
Can constructor be static in c++?
What is a storage class?
What are the various oops concepts in c++?
How many static variables are created if you put one static member into a template class definition?
Why was c++ made?
What are formatting flags in ios class?
Difference between declaration and definition of a variable.
What does 7/9*9 equal ? a) 1 b) 0.08642 c) 0
What's the most powerful programming language?
Define vptr.
Why is c++ so fast?
What is function declaration in c++ with example?
Briefly describe a B+ tree. What is bulk loading in it?
Difference between strdup and strcpy?