Engineer Atlas
OverviewLearnVisualizerAlgorithm FinderPatternsComplexityRoadmapPracticeInterview
OverviewLearnVisualizerAlgorithm FinderPatternsComplexityRoadmapPracticeInterviewCheat SheetCompare
Data Structures
  • Fundamentals
  • Stack & Queue
  • Hashing
  • Trees
  • Heaps
  • Graphs
  • Specialized Structures
Algorithms
  • Searching
  • Sorting
  • Two Pointers
  • Sliding Window
  • Prefix Techniques
  • Recursion & Backtracking
  • Divide & Conquer
  • Greedy
  • Dynamic Programming
  • Graph Algorithms
  • String Algorithms
  • Bit Manipulation
  • Mathematical Algorithms
Learn/Data Structures/Stack & Queue
Stack/Queue

Stack & Queue

LIFO and FIFO containers, deques, monotonic variants and priority queues.

Stack
▶ viz

A last-in, first-out collection where all insertions and removals happen at one end, the top.

O(n) search · O(n) space
Queue
▶ viz

A first-in, first-out collection: elements enter at the back and leave from the front.

O(n) search · O(n) space
Circular Queue
▶ viz

A fixed-capacity queue over an array whose head and tail indices wrap around using modular arithmetic.

O(n) search · O(k) space
Deque
▶ viz

A queue that supports O(1) insertion and removal at both the front and the back.

O(n) search · O(n) space
Monotonic Stack
▶ viz

A stack whose elements are kept in sorted order by popping everything that would violate the order before each push.

O(n) search · O(n) space
Monotonic Queue
▶ viz

A deque kept in sorted order so the max (or min) of a sliding window is always at the front.

O(k) search · O(k) space
Priority Queue
▶ viz

An abstract queue where the element with the highest (or lowest) priority is always removed first, typically backed by a binary heap.

O(n) search · O(n) space
Engineer Atlas
GitHub·LinkedIn