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 code reusability in c++?
what is software cycle? What is a mission critical system ? What is the important aspect of a real-time system ? Explain the difference between microkernel and macro kernel. Give an example of microkernel.Why paging is used ? Which is the best page replacement algo and Why ? What is software life cycle ? How much time is spent usually in each phases and why Which one do U want to work if selected in Honeywell ? Which are the different types of testing ? What is a distributed system ? Some questions about CSP. Which languages do U know ? What are the differences between Pascal and C. questions from Compiler construction and Lisp. Which are the different computer architecture? What is the requirement in MIMD ? What is the difference between RISC and CISC processors ? Difference between loosely coupled and tightly coupled systems ? What is an open system?
What is private inheritance?
What is lazy initialization in c++?
What is virtual function? Explain with an example
What is #include iostream in c++?
Will a recursive function without an end condition every quit, in practice a) Compiler-Specific (Some can convert to an infinite loop) b) No c) Yes
What is a set in c++?
Describe public access specifiers?
What is array in c++ example?
What is a class template?
Is it possible to use a new for the reallocation of pointers ?
Is it possible to get the source code back from binary file?
What is meant by iomanip in c++?
How many standards of c++ are there?