Stacks & Queues
Master LIFO and FIFO data structures with visual push, pop, enqueue, and dequeue operations.
Step 1: What are Stacks & Queues?
Stacks and Queues are two of the most fundamental data structures in computer science. They both store collections of elements, but differ in the order elements are added and removed.
Stack — LIFO (Last In, First Out): Think of a stack of plates. You add plates to the top and remove from the top. The last plate placed is the first one taken off.
Queue — FIFO (First In, First Out): Think of a line at a store. The first person in line is the first to be served. New people join at the back.
Key Terms:
- Push — Add an element to the top of a stack
- Pop — Remove the top element from a stack
- Enqueue — Add an element to the rear of a queue
- Dequeue — Remove the element from the front of a queue
- Peek — View the top (stack) or front (queue) element without removing it
- Top — The most recently added element in a stack
- Front / Rear — The first and last elements in a queue
Stack (LIFO)
Queue (FIFO)
About This Lab
How It Works
- 1 Read each step's explanation
- 2 Push and pop items on the interactive stack
- 3 Enqueue and dequeue items in the interactive queue
- 4 Solve bracket matching and other exercises
- 5 Complete the quiz to test your understanding
More Labs in Data Structures
Hash Tables & Hash Maps
Data StructuresVisualize hashing, collisions, and key-value storage with an interactive hash table simulator.
Linked Lists
Data StructuresVisualize singly and doubly linked lists — insert, delete, search, and traverse nodes interactively.
Binary Search Trees
Data StructuresBuild and traverse binary search trees — insert, search, delete nodes with animated tree visualizations.