Write a program to reverse a linked list?
Answer Posted / prakash d
struct node *ptr1,*ptr2,*ptr3;
ptr1=start; //pointer points to starting node.
ptr2=ptr1->next;
ptr3=ptr2->next;
ptr1->next=NULL;
ptr2->next=ptr1;
while(ptr3!=NULL)
{
ptr1=ptr2;
ptr2=ptr3;
ptr3=ptr3->next;
ptr2->next=ptr1;
}
start=ptr2;
| Is This Answer Correct ? | 13 Yes | 6 No |
Post New Answer View All Answers
Why c++ is faster than java?
what is upcasting in C++?
What is general format for a prototype?
If you push the numbers (in order) 1, 3, and 5 onto a stack, which pops out first a) 1 b) 5 c) 3
What is using namespace std in c++?
How do you find out if a linked-list has an end? (I.e. The list is not a cycle)
What is singleton pattern in c++?
Why c++ is the best language?
What is meant by const_cast?
Can the creation of operator** is allowed to perform the to-the-power-of operations?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
Which is best c++ or java?
Can a Structure contain a Pointer to itself?
What is constructor in C++?
How are Structure passing and returning implemented by the compiler?