View on GitHub

401-data-structures-and-algorithms

stack-and-queue

Using a Linked List as the underlying data storage mechanism, implement both a Stack and a Queue

whiteboard

link to whiteboard image

Approach & Efficiency

Stack: peek() is O(1) pop() is O(1) push() is O(1) isEmpty() is O(1)

Queue: enqueue() is O(n) dequeue() is O(1) peek() is O(1) isEmpty() is O(1)

JavaScrip file link to github ➜

Go to table of contents