Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Pinterest
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Reverse The Doubly Linked List

Objec­tive: Reverse The Dou­bly Linked List.

Exam­ple:

Reverse-The-Doubly-Linked-List

Reverse-The-Doubly-Linked-List

Approach:

  • Every Node in a dou­bly linked list has next and pre­vi­ous pointer.
  • Do the lin­ear tra­ver­sal of the linked list and keep swap­ping the next and pre­vi­ous pointers.
  • At the end, make the last pointer as the head of the list.

Com­plete Code:


Out­put:

->4->3->2->1
->1->2->3->4

You may also like...