- Home
- Courses
- DSA for Interviews
- Trees, Graphs, and Recursion
Micro Free Course — 100% Free Learning
All lessons in this module are free to learn. Sign in with Google to save your progress.
Trees, Graphs, and Recursion
Recursion and backtracking; binary trees and traversals (DFS pre/in/post, BFS level order); BSTs and heaps; graph representations and BFS/DFS; weighted-graph algorithms (Dijkstra, topological sort).
Module Content
Recursion & Backtracking
The mental model: solve a smaller problem; combine. Backtracking adds 'undo' for exploring all possibilities. FIND_VIDEO: search 'recursion backtracking interview pattern explained' — recommended channel: NeetCode / Abdul Bari. Aim for 12 min or under.
Recap — Recursion and Backtracking Templates
How to write any recursive function: base case + recursive case. The backtracking template that solves subsets, permutations, combinations.
Binary Trees & Traversals
Pre-order, in-order, post-order, level-order. The four traversals you'll be asked about in every tree problem. FIND_VIDEO: search 'binary tree traversal DFS BFS interview' — recommended channel: NeetCode / Abdul Bari. Aim for 11 min or under.
Recap — Tree Traversal Patterns
DFS vs BFS, the three DFS orderings, and when each is the right tool for a tree problem.
Binary Search Trees & Heaps
BST: ordered tree, O(log N) operations. Heap: complete tree for priority queue, O(log N) push/pop. FIND_VIDEO: search 'binary search tree heap priority queue interview' — recommended channel: NeetCode / Abdul Bari. Aim for 10 min or under.
Recap — BST and Heap Mental Models
When you need ordered traversal — BST. When you need top-K or 'always the min/max' — heap.
Graphs: Representation & BFS/DFS
Adjacency list vs matrix. BFS for shortest unweighted path; DFS for connectivity and exploration. FIND_VIDEO: search 'graph BFS DFS representation interview' — recommended channel: NeetCode / William Fiset. Aim for 12 min or under.
Recap — Graph Representation and Traversal
The three ways to represent a graph; when BFS beats DFS; the patterns for grid/matrix problems treated as graphs.
Graph Algorithms (Dijkstra, Topological Sort)
Weighted shortest path (Dijkstra) and dependency ordering (topo sort). The two named algorithms most likely to appear. FIND_VIDEO: search 'dijkstra topological sort algorithm explained' — recommended channel: NeetCode / Abdul Bari. Aim for 11 min or under.
Recap — Dijkstra and Topological Sort
Both algorithms come up regularly. Templates and the problem signals that trigger each.