How many pointers are required to reverse a link list?

Answer Posted / vivek

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;
}
}

}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a c++ vector?

588


What is the difference between strcpy() and strncpy()?

606


What is the basic structure of a c++ program?

608


how to explain our contribution in the project?

3073


What programming language should I learn first?

584






Can I create my own functions in c++?

592


Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300

1783


Explain the benefits of proper inheritance.

636


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

1853


How does a C++ structure differ from a C++ class?

617


How long does it take to get good at leetcode?

654


Do the parentheses after the type name make a difference with new?

640


Define vptr.

592


How much is c++ certification?

581


What do you understand by zombie objects in c++?

608