Lab 9 :: Stacks and doubly linked lists

This lab has two small problems. You are required to do both.

1. Stack of integers

Stacks are an abstract datatype which allow data to be stored and retrieved in "last in first out" manner. You are asked to implement a stack of integers which stores these integers internally as a linked list.

A stub class is provided here Stack.java, which gives the description of the methods to be implemented. Fill in rest of the code in this class.

2. Doubly linked lists

In a doubly linked list each node has two links one to the previous node and another to the next node. This provides some flexibility if we wish to traverse in both directions from a given node. Also deletion in doubly linked list is simple, as we can directly delete node without having a reference to its previous node.

Design classes Dnode and Dlist in analogus way to classes Node and List we saw in lectures (the code for these classes is also on the website). In class DList implement some common methods like: add, delete, append, reverse.

You may give either recursive of iterative code for these methods.