The Problem
We often treat Data Structures and Algorithms (DSA) like a grocery list. We pick "Heaps" today and "Graphs" tomorrow. But computer science topics have dependencies. You cannot understand Heaps if you don't understand Arrays (how they are stored) and Trees (how they are visualized).
I created a 7-Phase Roadmap tailored to build a mental model step-by-step. This order ensures that every new topic uses tools you mastered in the previous phase.
🏗️ Phase 1: Basic Linear Structures & Their Patterns Goal: Mastering sequential data and index manipulation. Before touching complex nodes, master the line.
Time & Space Complexity (Big-O): The measuring stick for all code.Arrays: Memory models (Static vs Dynamic).
Searching and sorting Algorithms: Essential pre-requisite for Two Pointers.
Recursion (Pattern): Just the basics (Base case vs Recursive case).Two Pointers (Pattern): The most common array optimization.
Binary Search (Algorithm): $O(\log N)$ logic.
Sliding Window (Pattern): Subarrays and substrings.
Prefix Sum (Pattern): 1D and 2D range queries.Intervals (Pattern): Merging and inserting ranges.
Matrix Traversal (Pattern): Basics of iterating 2D grids.
🔍 Phase 2: The Power of Lookup (Hashing)Goal: Trading space for speed.
Hash Table / Hash Map: The $O(1)$ lookup king.
Strings: Immutability and manipulation techniques.
🔗 Phase 3: Pointers & Recursion Goal: Moving from Indexes to References.
Linked List: Single and Doubly linked.
Recursion (Advanced): Multiple recursive calls (Memoization prep).
Stack & Queue: LIFO and FIFO mechanics.
Monotonic Stack (Pattern): Finding the "next greater element.
"Fast & Slow Pointers (Pattern): Cycle detection.
🌳 Phase 4: Non-Linear Structures (Hierarchical)Goal: Parent-Child relationships.
Trees: Height, depth, diameter properties.
Binary Trees: The standard interview structure.
Tree Traversals: Preorder, Inorder, Postorder, Level-order.
Binary Search Tree (BST): Sorted hierarchical data.
Heaps / Priority Queue: Organizing by priority.
Top K Elements (Pattern): Using Heaps efficiently.
Divide and Conquer (Pattern): Merge Sort logic applied to trees.
🕵️ Phase 5: Advanced Search & BacktrackingGoal: Exploring all possibilities.
Backtracking (Pattern): Solving puzzles (Sudoku, N-Queens).
Tries: Prefix trees for autocomplete.
🌐 Phase 6: Connectivity (Graphs)Goal: Many-to-Many relationships.
Graphs: Adjacency Matrix vs. Adjacency List.
Matrix Traversal (Advanced): Treating Grids as Graphs.
Graph Traversals: BFS (Shortest path in unweighted) & DFS.
Union Find: Disjoint Set Union (DSU).
Shortest Path: Dijkstra's Algorithm.
🚀 Phase 7: Optimization (The Hardest Part)Goal: Solving overlapping sub-problems.
Bit Manipulation: Binary logic.
Dynamic Programming (DP):
The pipeline: Recursion → Memoization → Tabulation → Space Optimization.
Why this order?
Recursion is Split: You need basic recursion for sorting, but advanced recursion for Trees and DP.
Matrix is Split: You need to know how to loop through a matrix (Phase 1) before you can run BFS on it (Phase 6).
Patterns First: We learn "Two Pointers" immediately after Arrays because that is how you actually use arrays in the real world.
Save this roadmap and stop getting lost in the noise! 🚀
==> Data Structures
=> Linear
. Array
. Strings
. Linked List
. Stack
. Queue
. Deque
. Hash Table / Hash Map
=> Non-Linear
. Trees
. Binary Search Tree (BST)
. Heaps / Priority Queue
. Segment Tree / Fenwick Tree (BIT)
. Graphs
. Tries
. Union Find (Disjoint Set)
==> Algorithms
. Linear Search
. Basic Sorting (Bubble, Selection, Insertion)
. Merge Sort / Quick Sort
. Cyclic Sort
. Binary Search
. Modified Binary Search
. Bit Manipulation
. Tree Traversals
. Graph Traversals
. Topological Sort
. Shortest Path (Dijkstra / Bellman-Ford / Floyd-Warshall)
. Minimum Spanning Tree (Kruskal's / Prim's)
==> Patterns
. Two Pointers
. Fast & Slow Pointers
. Sliding Window
. Prefix Sum
. Intervals
. Cyclic Sort ← borderline pattern/algorithm, fits both
. Matrix Traversal
. Monotonic Stack/Queue
. Divide & Conquer
. Greedy
. Recursion
. Backtracking
. Top K Elements (Heap)
. K-way Merge
. Dynamic Programming
====> order of learning
=> Phase 1: Basic Linear Structures & Their Patterns
. Time & Space Complexity (Big-O)
. array
. strings
. Recursion (pattern) [base case, recursive case, call stack visualization]
. searching (Algorithm) [Linear Search]
. Basic Sorting (Bubble, Selection, Insertion)
. two pointers (pattern)
. binary search (algorithm)
. Modified Binary Search
. sliding window (pattern)
. Cyclic Sort
. prefix sum (pattern) [(1D and 2D)]
. Intervals (Pattern)
. Matrix Traversal (Pattern) [indexing, 2D prefix sum]
=> Phase 2: The Power of Lookup (Hashing)
. hash table /hash map
. Greedy (Pattern)
=> Phase 3: Pointers & Recursion
. linked list
. Recursion (pattern) [multiple recursive calls, memoization prep, linked list recursion]
. sorting (Merge sort, Quick sort)
. Divide and Conquer (Pattern)
. stack
. queue
. Deque (Double-ended Queue)
. Monotonic Stack/Queue (pattern)
. fast and slow pointers (pattern)
=> Phase 4: Non-Linear Structures (Hierarchical)
. Trees and properties (height, depth, diameter)
. binary trees
. Tree Traversals (Algorithm) [(preorder, inorder, postorder, level-order)]
. Binary Search Tree (BST)
. Heaps / Priority Queue
. Segment Tree / Fenwick Tree (BIT)
. Top K Elements (Pattern)
. K-way Merge
=> Phase 5: Advanced Search & Backtracking
. Backtracking (Pattern)
. Tries
=> Phase 6: Connectivity (Graphs)
. Graphs and Graph representations (Adjacency List / Matrix)
. Matrix Traversal (Pattern) [(DFS/BFS on grids)]
. Graph Traversals (Algorithm)
. Topological Sort
. Union Find (Disjoint Set)
. Shortest Path (Algorithm) (Dijkstra / Bellman-Ford / Floyd-Warshall)
. Minimum Spanning Tree (Kruskal's / Prim's)
=> Phase 7: Optimization (The Hardest Part)
. Bit Manipulation (algorithm)
. Dynamic Programming (pattern) [Recursion → Memoization. Tabulation. Space Optimization]
Top comments (0)