Learn the idea. Then follow the steps.
Start with how to count the work an algorithm does. Each later lesson uses that count.
Start here Check whether the Python examples will feel familiar Search the glossary and compare Python tools
Course
Search titles, descriptions, stages, and recommended prerequisites.
Linear structures · 0 of 10 done
Follow links, stacks, and queues, and keep both neighbors when a node can move.
- Singly linked listGuide
Trace how nodes and a cached tail support list operations with different costs.
Learning outcomes 2
- Trace node links and list invariants
- Compare append, search and indexed access costs
Recommended first: Arrays and Python sequence costs
Use pointer speed and a fixed gap to find middles, detect cycles, and locate nodes from the end.
Learning outcomes 2
- Explain fast/slow pointer middle and cycle behavior
- Use a fixed gap to locate a node from the end
Recommended first: Singly linked list
Preserve every node while reversing or rearranging links in a chain.
Learning outcomes 2
- Maintain reversed prefix and untouched suffix
- Identify reconnection boundaries for relinking operations
Recommended first: Singly linked list
Combine ordered linked lists and use bottom-up merging to sort without random access.
Learning outcomes 2
- Merge sorted chains by comparing their heads
- Derive bottom-up merge-sort time and auxiliary space
Recommended first: Singly linked list
Read the preconditions behind duplicate removal, node deletion, digit lists, and circular splits.
Learning outcomes 2
- State specialized linked-list preconditions
- Choose boundary tests for unusual input shapes
Recommended first: Singly linked list
Maintain both neighbor links during insertion, removal, and movement of known nodes.
Learning outcomes 2
- Update both neighbors when inserting or removing a node
- Explain why a known-node unlink is constant time
Recommended first: Singly linked list
- Stack basicsGuide
Trace last-in, first-out operations and maintain a bounded stack's size invariant.
Learning outcomes 2
- Trace LIFO order
- State bounded stack size invariants
Recommended first: Arrays and Python sequence costs
Use a monotonic stack to resolve next-greater and related candidates in linear total work.
Learning outcomes 2
- Trace unresolved candidates and pops
- Derive linear total work from one push/pop per item
Recommended first: Stack basics
Apply stack order to nested delimiters, operator precedence and auxiliary stack patterns.
Learning outcomes 2
- Use a stack to match nested delimiters
- Trace operator precedence using an operator stack
Recommended first: Stack basics
Compare FIFO and double-ended operations with linked and circular-buffer invariants.
Learning outcomes 2
- Trace FIFO order
- Compare linked and circular queue invariants
Recommended first: Arrays and Python sequence costs, Singly linked list
Search and ordering · 0 of 8 done
Sort, then use that order to search and to pick one rank.
- Comparison sortsGuide
Compare simple sorting invariants, input sensitivity and stability.
Learning outcomes 2
- Compare simple sorting invariants
- Relate input order to best-case work and stability
Recommended first: Arrays and Python sequence costs, Recursion and recurrences
- Merge sortGuide
Derive merge sort's work from its levels and account for merge storage.
Learning outcomes 2
- Trace a stable merge
- Derive time and auxiliary-space costs
Recommended first: Comparison sorts, Recursion and recurrences
Use a partition invariant and relate pivot balance to quicksort's cost.
Learning outcomes 2
- State a partition invariant
- Relate pivot splits and duplicates to time and stack cost
Recommended first: Comparison sorts
- Binary searchInteractive pilot
Trace why a sorted sequence lets each comparison rule out half the remaining indexes.
Learning outcomes 4
- Justify why sorted order lets each comparison discard a range
- Trace present, missing and duplicate values
- Diagnose a non-shrinking interval
- Separate search and insertion costs
Recommended first: Comparison sorts
Search a monotonic feasibility decision and account for each check's cost.
Learning outcomes 3
- State when a feasibility predicate is monotone
- Trace how feasible and infeasible candidates preserve the boundary invariant
- Multiply feasibility-check cost by the number of candidate rates
Recommended first: Binary search
Use bounded ranges and digit passes when key structure permits non-comparison sorting.
Learning outcomes 2
- Relate counting-sort cost to key range
- Explain stable digit passes and radix cost
Recommended first: Comparison sorts
Find one sorted rank with quickselect without ordering every item.
Learning outcomes 2
- Trace quickselect's remaining side
- Compare expected and worst-case work
Recommended first: Quicksort and partition
- Inversion countingGuide
Count out-of-order pairs while merging sorted runs.
Learning outcomes 2
- Define an inversion
- Count cross-run inversions during merge
Recommended first: Merge sort
Lookup and priority · 0 of 8 done
Look up keys, keep a search tree ordered, and pick the next item by priority.
Trace collision buckets and understand how load factor relates to expected chain length.
Learning outcomes 2
- Trace entries in collision buckets
- Relate load factor and resizing to expected lookup
Recommended first: Arrays and Python sequence costs
Trace open-addressing probes, tombstones, and clustering in a table array.
Learning outcomes 2
- Trace a probe sequence through collisions and tombstones
- Explain clustering and table load effects
Recommended first: Hash tables with chaining
- LRU cacheGuide
Combine constant-expected-time key lookup with recency ordering and eviction.
Learning outcomes 2
- Trace promotion and least-recent eviction
- Relate dictionary and list operations to cache complexity
Recommended first: Hash tables with chaining, Doubly linked-list operations
Trace ordered lookup, insertion, deletion, and successor operations in a BST.
Learning outcomes 2
- Trace BST lookup, insertion and deletion
- Find a successor while preserving ordering
Recommended first: Binary search
- Tree traversalsGuide
Compare depth-first and level-order traversals and predict their visit orders.
Learning outcomes 2
- Predict preorder, inorder and postorder sequences
- Trace level-order traversal with a queue
Recommended first: Binary search tree operations, Queue and deque operations
Explain how balancing keeps search-tree height logarithmic through rotations.
Learning outcomes 2
- Explain why balance bounds search-tree height
- Relate local rotations to preserved key order
Recommended first: Binary search tree operations
- Heap operationsGuide
Trace heap insertion, removal, heap construction, and heapsort using array indexes.
Learning outcomes 2
- Trace sift-down and heap construction
- Derive heapsort's time and extra-space costs
Recommended first: Arrays and Python sequence costs
- Priority queuesGuide
Choose a priority-queue operation and explain the heap cost behind it.
Learning outcomes 2
- Map priority-queue operations to heap operations
- Choose between repeated extraction and sorting once
Recommended first: Heap operations
Graphs · 0 of 6 done
Model connections, walk them, and build a spanning tree without cycles.
Choose adjacency lists or matrices based on graph density and required operations.
Learning outcomes 2
- Compare adjacency-list and matrix space
- Choose representation for graph operations
Recommended first: Arrays and Python sequence costs
- Graph traversalsGuide
Trace depth-first and breadth-first search and account for visited state.
Learning outcomes 2
- Trace DFS and BFS discovery
- Explain O(V + E) traversal work
Recommended first: Graph representations, Queue and deque operations
Order dependency graphs and detect cycles using indegrees.
Learning outcomes 2
- Trace Kahn's algorithm
- Detect when a directed cycle prevents full ordering
Recommended first: Graph traversals
- Shortest pathsGuide
Choose BFS or Dijkstra from edge weights and trace relaxation correctly.
Learning outcomes 2
- Choose BFS or Dijkstra from weight assumptions
- Trace edge relaxation and implementation costs
Recommended first: Graph traversals, Heap operations
- Union-findGuide
Track which items are connected as sets merge, with and without balancing heuristics.
Learning outcomes 2
- Track components as sets merge
- Explain path compression and union-by-rank
Recommended first: Graph representations
Trace Kruskal's algorithm and use union-find to avoid cycles.
Learning outcomes 2
- Trace Kruskal's edge choices
- Explain cycle checks and forest behavior
Recommended first: Union-find, Graph representations
Problem-solving methods · 0 of 7 done
Recognize a pattern, then account for its cost.
- Two-pointer patternsGuide
Use a movement invariant to justify scans from ends, gaps, or paired inputs.
Learning outcomes 2
- State why a pointer may safely move
- Account for total monotone pointer movement
Recommended first: Arrays and Python sequence costs, Loop invariants
- Sliding windowsGuide
Maintain a contiguous range as it grows and shrinks under a valid monotone condition.
Learning outcomes 2
- Maintain a valid contiguous window
- Identify when monotonicity assumptions fail
Recommended first: Two-pointer patterns
- Prefix sumsGuide
Answer range-sum queries and count target-sum subarrays from cumulative totals.
Learning outcomes 2
- Derive half-open range sums
- Count target subarrays using prior prefix frequencies
Recommended first: Arrays and Python sequence costs
- Backtracking searchGuide
Explore choice trees with reversible state, safe pruning and explicit search costs.
Learning outcomes 2
- Trace choose, recurse and undo
- Estimate search-tree size and justify pruning
Recommended first: Recursion and recurrences
- Greedy methodsGuide
Evaluate a locally best choice and justify it with a structural proof.
Learning outcomes 2
- State a greedy decision rule
- Distinguish examples from a correctness proof
Recommended first: Comparison sorts
- Dynamic programmingGuide
Turn repeated subproblems into bottom-up tables and analyze time and memory separately.
Learning outcomes 3
- Identify repeated subproblems and state
- Build a bottom-up recurrence
- Analyze time and memory separately
Recommended first: Recursion and recurrences
Define dynamic-programming states, transitions, base cases, fill order and cost.
Learning outcomes 2
- Define a state and recurrence
- Count state, transition and memory costs
Recommended first: Dynamic programming
Advanced applications · 0 of 6 done
Apply the same ideas to text, ranges, storage, and approximation.
Trace KMP fallback and rolling-hash candidate verification for pattern matching.
Learning outcomes 2
- Trace KMP fallback after mismatch
- Explain candidate verification in Rabin–Karp
Recommended first: Arrays and Python sequence costs
Compare prefix tries and text indexes by query, build cost and storage.
Learning outcomes 2
- Match text queries to indexes
- Include construction and output costs
Recommended first: String search algorithms
Choose Fenwick trees, segment trees or sparse tables from update and query needs.
Learning outcomes 2
- Compare update and query support
- Choose a range structure for a workload
Recommended first: Cost models and assumptions
Explain Bloom-filter guarantees, false positives and workload assumptions.
Learning outcomes 2
- Distinguish Bloom-filter maybe and absent results
- Relate false positives to memory and probes
Recommended first: Hash tables with chaining
Compare B-tree and LSM costs across reads, writes and locality.
Learning outcomes 2
- Compare B-tree and LSM work placement
- Explain effects of locality and storage reads
Recommended first: Balanced search trees, Range-query structures
Prove feasibility and a factor-two bound for a vertex-cover construction.
Learning outcomes 2
- Prove the constructed set is a vertex cover
- Derive the factor-two approximation guarantee
Recommended first: Greedy methods
Python reference
Module maps and small language examples. These pages are not part of the numbered sequence.
- Analysis and library costsReference
Estimate the work and memory an algorithm uses, including the cost of common Python operations.
Learning outcomes 2
- Estimate loop and recursion work
- Compare common Python collection operations
- List algorithmsReference
Use pointer patterns to reverse, rotate, merge, and inspect linked lists.
Learning outcomes 2
- Use slow/fast and split/merge pointer patterns
- Explain how each pointer update preserves list structure
Recommended first: Singly linked list
- StacksReference
Use last-in, first-out behavior for parsing, monotonic scans, and stack-based algorithms.
Learning outcomes 2
- Apply last-in, first-out behavior
- Recognize stacks in parsing and monotonic scans
Recommended first: Stack basics
- Queues and dequeReference
Compare FIFO queues, ring buffers, dynamic arrays, and deques by where operations happen.
Learning outcomes 2
- Distinguish FIFO queues from deques
- Choose an implementation based on which ends change
Recommended first: Queue and deque operations
- SortingReference
Compare simple and efficient sorting algorithms by work, memory, stability, and input order.
Learning outcomes 2
- Compare sorting work and memory
- Choose a sort based on stability and input characteristics
Recommended first: Comparison sorts
- Sorting extrasReference
Extend comparison sorting with radix methods and order-statistic selection.
Learning outcomes 2
- Identify when radix sorting avoids comparison sorting
- Use selection to find order statistics
Recommended first: Counting and radix sorts, Order-statistic selection
- HeapsReference
Maintain a partial order when the next smallest or largest item matters most.
Learning outcomes 2
- Maintain a heap's partial-order invariant
- Use a priority queue for repeated minimum/maximum selection
Recommended first: Heap operations
- Hash tableReference
Use hashes for expected fast lookup and see what collisions do to that expectation.
Learning outcomes 2
- Trace hashing, buckets and collisions
- Distinguish expected lookup cost from worst-case cost
Recommended first: Hash tables with chaining
- Binary search treeReference
Walk ordered keys through ordinary and balanced search trees, and relate height to cost.
Learning outcomes 2
- Trace ordered lookup and tree edits
- Relate tree height and balancing to operation cost
Recommended first: Binary search tree operations
- Doubly linked list and the LRU cacheReference
Connect two-way links with key lookup to build an LRU cache.
Learning outcomes 2
- Maintain next and previous links during edits
- Combine key lookup and recency order in an LRU cache
Recommended first: Doubly linked-list operations, LRU cache
- GraphsReference
Represent relationships and trace traversals, shortest paths, and spanning-tree algorithms.
Learning outcomes 3
- Choose graph representations
- Trace traversal and shortest-path algorithms
- Compare spanning-tree strategies
Recommended first: Graph representations
- Greedy algorithmsReference
Choose locally useful steps and examine when that choice leads to a global optimum.
Learning outcomes 2
- State a greedy choice
- Use an exchange or cut argument to justify optimality
Recommended first: Greedy methods
- Backtracking and array patternsReference
Search a space of choices and recognize two-pointer, window, prefix-sum, and deque patterns.
Learning outcomes 2
- Represent choices as a search tree
- Recognize two-pointer, window and prefix-sum patterns
Recommended first: Two-pointer patterns, Backtracking search
- StringsReference
Search, index, and compress text with tries, pattern matching, hashes, and suffix arrays.
Learning outcomes 2
- Compare text-search and indexing methods
- Choose between tries, hashes and pattern matching
Recommended first: String search algorithms
Answer exact range questions and understand the tradeoffs of probabilistic structures.
Learning outcomes 2
- Select a range-query structure for its update/query tradeoff
- Explain false positives and guarantees in approximate structures
Recommended first: Range-query structures
- Storage and localityReference
Connect in-memory trees, write-ahead logs, sorted runs, and locality to storage-engine behavior.
Learning outcomes 2
- Relate tree, log and sorted-run structures to storage engines
- Explain why access locality changes practical performance
Recommended first: Storage engines and locality
- Limits and approximationReference
Separate what can be solved exactly from what needs an approximation or an assumption.
Learning outcomes 2
- Separate exact, approximate and assumption-dependent claims
- Interpret a factor-two vertex-cover guarantee
Recommended first: Approximation guarantees
- Appendix: Python toolsReference
Look up small Python decorator and directory-walking examples when needed.
Learning outcomes 1
- Look up decorator and directory-walking examples