How to reverse all the no using a single link list.

Questions by gudia

Showing Answers 1 - 1 of 1 Answers

Let list be the pointer pointing to the list.

Take 3 pointers.
struct node

{

       int data;
       struct node * next;
}

struct node * reverse( struct node *list)

{
struct node * previous, *last;


          previous = list;

          list = list ->next;

          last = list->next;

    while (list->next != NULL)

    {

         list->next = previous;

         previous = list;

         list = last;

         last= last ->next;

     }


return list;

}


  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions