Algorithms Tutorial

Sorting, searching, recursion and Big-O — how to reason about whether code is actually fast.

Start the Algorithms tutorial →

What you'll learn

1. Algorithms Introduction
What an algorithm is, why the same problem can have wildly different-speed solutions, and a Big-O refresher.
2. Recursion
Base and recursive cases, the call stack visualized, naive vs memoized Fibonacci, and when recursion risks trouble.
3. Sorting Algorithms
Bubble sort, merge sort, and quicksort with full code, a complexity/stability comparison table, and when to just use sorted().
4. Searching Algorithms
Linear vs binary search, why binary search needs sorted data, and solving search in a rotated sorted array.
5. Two Pointers & Sliding Window
Two-pointer two sum and array reversal, sliding window for max subarray sum and longest unique substring, and why both beat O(n²).
6. Divide and Conquer
The divide/conquer/combine pattern, merge sort and binary search revisited through it, and how it differs from dynamic programming.
7. Dynamic Programming
Overlapping subproblems and optimal substructure, top-down vs bottom-up on climbing stairs, and 0/1 knapsack solved with a table walkthrough.
8. Greedy Algorithms
What makes a choice greedy, a coin-change counterexample where greedy fails, and activity selection solved correctly with greedy.
9. Graph Algorithms
Dijkstra's algorithm for weighted shortest paths, when to reach for Bellman-Ford instead, and a complete Union-Find implementation.
10. Big-O Analysis in Practice
How to read nested loops and recursive calls, amortized analysis of dynamic array append, and worked Big-O walkthroughs.
11. Algorithms Interview Questions
Commonly asked algorithms interview questions with clear, practical answers.