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
What is an associative container in c++?
Can you explicitly call a destructor on a local variable?
Does c++ have a hash table?
If you don’t declare a return value, what type of return value is assumed?
Differentiate between the message and method in c++?
Which command properly allocates memory a) char *a=new char[20]; b) char a=new char[20]; c) char a=new char(20.0);
What are move semantics?
What does the linker do?
Can c++ do everything c can?
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
Which programming language's unsatisfactory performance led to the discovery of c++?
What is the difference between interpreters and compilers?
What are the four main data types?
What is the arrow operator in c++?
What is the basic structure of a c++ program?