Stacks & Queues

Module Contents

  1. Introduction to Stacks & Queues

Understand Stacks (LIFO) and Queues (FIFO). The hardware reality of ‘Push’ and ‘Pop’. Why Recursion is just a Stack.

  1. Stack Operations

Master Push, Pop, Peek. Implement a MinStack in O(1) time. Understand why ArrayDeque is superior to Stack in Java.

  1. Queue Implementations

Master FIFO. Implement Queues using Linked Lists and Ring Buffers (Circular Arrays). Understand the trade-offs.

  1. Monotonic Stack

Master the Monotonic Stack pattern. Solve the Next Greater Element problem in O(N) time.

  1. Expression Evaluation

Build a Calculator. Learn the Shunting-yard algorithm to convert Infix to Postfix (RPN) and evaluate expressions.

  1. Sliding Window Maximum

Solve the Hard Sliding Window Maximum problem in O(N) using a Monotonic Deque.

  1. Real World Applications

How Stacks and Queues are used in the real world: Browser History, Undo/Redo, CPU Scheduling, and Rate Limiting.

  1. Module Review: Stacks & Queues

Review everything you learned about Stacks and Queues. Flashcards, Cheat Sheet, and Key Takeaways.

Stacks & Queues

[!NOTE] This module explores the core principles of Stacks & Queues, deriving solutions from first principles and hardware constraints to build world-class, production-ready expertise.

1. Practice

[!NOTE] Looking for hands-on algorithmic exercises? We have migrated all coding challenges for this module into the Problem Vault to give you a centralized, focused practice environment.