Memory Guide
📖 SECTION 1: CORE DATA STRUCTURES
1. Arrays vs. Linked Lists
● Array: Fixed size, contiguous memory blocks.
○ Memory Analogy: A row of locked gym lockers placed
side-by-side.
○ Time Complexity: Look-up: O(1) | Access by Index: O(1) |
Insertion/Deletion: O(n)
● Linked List: Dynamic size, nodes connected via pointers.
○ Memory Analogy: A scavenger hunt where each clue gives
you the location of the next clue.
○ Time Complexity: Access/Search: O(n) | Insertion/Deletion at
Head: O(1)
2. Stacks & Queues
● Stack (LIFO - Last In, First Out):
○ Analogy: A stack of dinner plates or cafeteria trays. You add
to the top and take from the top.
○ Key Operations: push() (add), pop() (remove top), peek() (view
top).
○ Use Cases: Undo/Redo features, Call stack in execution,
Depth-First Search (DFS).
1
, ● Queue (FIFO - First In, First Out):
○ Analogy: A line of people waiting to buy concert tickets. The
first person in line gets served first.
○ Key Operations: enqueue() (add to back), dequeue() (remove
from front).
○ Use Cases: Print job scheduling, Breadth-First Search (BFS),
task queues.
3. Hash Tables
● Concept: Key-Value pairs mapped using a Hash Function.
● Analogy: An organized filing cabinet where every folder label
immediately tells you which drawer it is in.
● Time Complexity: Average Lookup/Insert/Delete: O(1) | Worst Case
(due to collisions): O(n)
● Handling Collisions:
○ Chaining: Storing multiple elements in a Linked List at the
same index.
○ Open Addressing: Finding the next available empty slot in
the array.
2