What an Algorithm Is — Correctness and Termination
You've written code that ran without errors and produced the wrong answer. Every working engineer has. The compiler can verify that your syntax is legal; it cannot verify that you…
Introduction to Algorithms and Complexity covers: Core Topics, Core Topics (continued). Year 1, Quarter 1. Includes 12 exercises and 2 projects.
This course unlocks once you've finished its prerequisite. Open prerequisite →
You've written code that ran without errors and produced the wrong answer. Every working engineer has. The compiler can verify that your syntax is legal; it cannot verify that you…
Two engineers argue about which of two functions is faster. One has timed them on her laptop and the first wins by 30 milliseconds. The other has timed them on his server and the …
Asymptotic notation gives you the vocabulary. Now you need the technique: looking at a piece of code and getting the Θ bound out of it without timing anything. That technique is c…
You wrote a recursive function in the last lesson. You worked out its recurrence: T(n) = T(n/2) + Θ(1) for binary search, T(n) = 2T(n/2) + Θ(n) for merge sort, T(n) = T(n-1) + T(n…
You're appending to a Ruby array in a loop. array << item looks like a constant-time operation — and most of the time it is. But every once in a while, Ruby's array implementation…
- [ ] Rank these functions by growth: n, n log n, n^2, 2^n, n!, log n, n^3 — Big O fluency - [ ] Analyze time complexity of Ruby's Array#include? vs Set#include? — O(n) vs O(1) - …
- [ ] Prove that O(n log n) + O(n) = O(n log n) — Formal Big O proof - [ ] Analyze time complexity of binary search (iterative and recursive) — Recurrence: T(n) = T(n/2) + O(1) - …
- [ ] Analyze average-case complexity of quicksort with random pivot — Recurrence with expected values - [ ] Prove the lower bound of comparison-based sorting: Omega(n log n) — De…
- [ ] Write a Ruby benchmarking suite — implement Benchmark.measure wrapper that tests Array vs Hash vs Set lookups on 10K, 100K, 1M elements; plot results with ASCII chart
Write a Ruby tool that takes a block of code, runs it with inputs of size 10, 100, 1000, 10000, measures wall-clock time, and fits the growth curve to O(1), O(log n), O(n), O(n lo…
Implement linear search, binary search, hash lookup, and tree lookup in Ruby. Benchmark all four on datasets of 1K to 1M elements. Generate a markdown report with timing tables. D…
- [ ] What is Big O notation? How does it differ from Big Omega and Big Theta? - [ ] Explain the difference between best case, worst case, and average case analysis. Which one do …
12 lessons. Read in order; spiral back when you need to. By the end you'll have used the core ideas twice — once on the abstract, once on something you'll meet at work next week.