class: center, middle
class: center, middle
Given an existing (doubly) linked list class, implement a stack class and a queue class. Do so via classical inheritance and then do so separately via composition. Then talk about which you would choose in this situation and why.
The linked list class has instance methods for addToHead
, addToTail
, removeFromHead
, and removeFromTail
.
The queue class should have instance methods for enqueue
and dequeue
. The stack class should have instance methods for push
and pop
.