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
Describe linked list using C++ with an example.
What are virtual functions in c++?
A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
What are guid? Why does com need guids?
Difference between inline functions and macros?
What is c++ hash?
Explain the difference between new() and malloc() in c++?
What is the use of data hiding?
What are the new features that iso/ansi c++ has added to original c++ specifications?
Carry out conversion of one object of user-defined type to another?
What is class syntax c++?
What is a binary file? List the merits and demerits of the binary file usagein C++.
Can a program run without main?
Why do we need c++?
How can an improvement in the quality of software be done by try/catch/throw?