reverse a doubly linked list

Write a program to reverse a doubly linked list.

Comments

  1. void reverse_doubly_linked_list(struct node* head)
    {
    struct node* ptr1=head;
    if(head->next==NULL) return;
    while(ptr1!=NULL)
    {
    struct node* agla=ptr1->next;
    struct node* temp=ptr1->next;
    ptr1->next=ptr1->previous;
    ptr1->previous=temp;
    ptr1=agla;

    }

    }

    ReplyDelete
  2. @ankit what is the use of using two different pointers agla and temp....can't it be done by temp only...

    ReplyDelete
  3. @priyaranjan go it :)

    ReplyDelete

Post a Comment

Popular posts from this blog