GeeksforGeeks » Linked List specific questions

Reversing doubly linked list

(5 posts)

Tags:

  1. k53
    Member
    Posted 5 months ago #

    Give an algorithm to reverse a doubly linked list in less than linear time

  2. kartik
    Moderator
    Posted 5 months ago #

    Reversing a DLL will take O(n) time if we use normal representation (prev and next pointers) for DLL. If DLL is implemented as XOR List (http://www.geeksforgeeks.org/archives/12367), then reversing a DLL is a simple O(1) operation. we just have to swap start and pointers.

  3. k53
    Member
    Posted 4 months ago #

    I'm getting a 'page not found' error clicking the link that yo have provided. Plz provide the current link

  4. kartik
    Moderator
    Posted 4 months ago #

  5. camster
    Member
    Posted 4 months ago #

    @kartik, Yes , swapping the head and tail pointers in an XOR DLL is an 0(constant operation) but it also also requires a complicated and bigger data structure for storing the addresses of the start/head and end/tail pointers of the XOR DLL. Thank you.


Reply

You must log in to post.

RSS feed for this topic