Dec 15, 2017

Linked-list implementations of Stack, Queue and Bag from the textbook Algorithms by Robert Sedgewick and Kevin Wayne

  • Linked list implementation of a stack. Stack.java implements a generic stack using a linked list. To push() an item, we add it to the beginning of the list; to pop() an item, we remove it from the beginning of the list.
  • Linked list implementation of a queue. Program Queue.java implements a generic FIFO queue using a linked list. To enqueue() an item, we add it to the end of the list; to dequeue() an item, we remove it from the beginning of the list.
  • Linked list implementation of a bag. Program Bag.java implements a generic bag using a linked list. The implementation is the same as Stack.java except for changing the name of push() to add() and removing pop().