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


Please Help Members By Posting Answers For Below Questions

There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.

2745


Explain shallow copy?

788


Describe protected access specifiers?

890


In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

958


How compile and run c++ program in turbo c++?

844


What are the differences between the function prototype and the function defi-nition?

823


Do you know about latest advancements in C++ ?

857


Which bit wise operator is suitable for putting on a particular bit in a number?

936


Which should be more useful: the protected and public virtuals?

772


What is the difference between public and private data members?

881


Write a program using display() function which takes two arguments.

818


What are the uses of typedef in a program?

814


How a new element can be added or pushed in a stack?

783


What are the methods of exporting a function from a dll?

845


What is dev c++ used for?

775