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
Why c++ is faster than java?
Difference between a homogeneous and a heterogeneous container
Where do I find the current c or c++ standard documents?
Write bites in Turbo c++ Header ("Include") Files.
Why pointer is used in c++?
What are the differences between the function prototype and the function defi-nition?
How does a copy constructor differs from an overloaded assignment operator?
Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .
What is doubly linked list in c++?
Why do we need templates?
What is a set in c++?
Is java made in c++?
What is the difference between mutex and binary semaphore?
What are manipulators used for?
Why the usage of pointers in C++ is not recommended ?