Saturday, November 9, 2013

Reversing a doubly linked list

Given a doubly linked list, how do we reverse it by just re-arranging the pointers?

Here is an example of input/output.

The following picture depicts how we re-arrange the pointers.


Here is the Java implementation.