$ mkdir ~/cs170/labs/lab28 $ cd ~/cs170/labs/lab28
A Stack is what we refer to as a "Last In, First Out" (LIFO) data structure. The data in a stack is placed an retrieved like a stack of plates at the commons: You can only interact with the top plate of the stack. The same can be said for the stack data structure: You can only interact with the most recently placed piece of data in the stack.
Create a class ListStack
which inherits the
Stack interface defined below. Your class should use
the LinkedList class to represent the stack.
Make sure you test your methods carefully. Think about what the edge cases are, and how to handle them appropriately.
A Queue is what we refer to as a "First in, First out" (FIFO) data structure. It behaves just like the line at the cavern. The person who entered the queue first will be served first, etc. In our data structure, that means the data that has been in the queue the longest will be processed next. This does not mean that we will keep track of that time. We will simply store elements in such a way that it gets processed correctly.
Create a class ListQueue
which inherits the
Queue interface defined below. Your class should use
the LinkedList class to represent the stack.
Make sure you test your methods carefully. Think about what the edge cases are, and how to handle them appropriately.