In this recipe, we will learn how to create a doubly linked list and how to traverse its elements in FIFO and LIFO order. As we explained in the introduction to this chapter, the node of a doubly linked list consists of two pointers: one points forward, while the other points backward. The pointer pointing forward is usually called next and is used to point at the next node. The other, which is pointing backward, is usually called prev and is used to point at the previous node.
Traversal in FIFO order means the elements of the doubly linked list are displayed in the order in which they were added to the list. Traversal is done by making use of the next pointer of the node.
Traversal in LIFO order means the elements are displayed in reverse or backward direction, and this traversal is done with the help of the prev pointer.
...