Data structures & algorithms
Learn to reason about performance, follow how data changes, and compare Python, Java, and JavaScript implementations.
Beginner
Arrays and prefix sums
Use indexed storage and build running totals to answer many range queries.
Big O and growth
Count work and explain how it grows when you give an algorithm more input.
Linear search
Find the first occurrence of an item by checking a list from left to right.
Binary search
Find a target in sorted data by ruling out half of the remaining values at each step.
Bubble sort
Sort an array through adjacent comparisons and see why each pass fixes one position.
Stacks and undo
Use last-in, first-out behavior to undo the most recent operation.
Queues and arrival order
Use first-in, first-out behavior to process jobs in the order they arrive.
Two pointers
Two pointers keep track of two useful positions while you scan data.
Sliding windows
A sliding window keeps a contiguous range and updates its result as the range moves.
Intermediate
Singly linked lists
Follow a chain of nodes and understand which updates are cheap when you have the right reference.
Hash maps and counting
Count values in one pass by storing a lookup table of items already seen.
Recursion and tree traversal
Visit tree branches with smaller calls and identify what stops each branch.
Breadth-first search
Explore an unweighted graph layer by layer and follow the queue as it changes.
Depth-first search
Explore one graph branch at a time and prevent a cycle from repeating your work.
Backtracking with choices
Build a candidate one choice at a time and restore the previous state after exploring each branch.
Merge sort
Merge sort splits a list into smaller parts, sorts each part, and merges the sorted parts.
Quicksort and partitioning
Quicksort groups elements around a pivot and sorts the remaining groups separately.
Heaps and priority queues
A priority queue gives you the next item by priority, and a binary heap is one way to store it.
Binary search trees
A binary search tree stores smaller keys on the left and larger keys on the right, with an explicit rule for duplicates.
Algorithm invariants
An invariant is a condition that remains true at a known point in each step of an algorithm.
Adjacency lists and matrices
A graph can store each vertex’s neighbors as a list or record every possible connection in a matrix.
Counting sort
Counting sort tracks how often each key occurs and then visits the keys in order.
Advanced
Dijkstra’s shortest paths
Find minimum-cost paths when edges have different nonnegative weights.
Dynamic programming
Build a table of useful subproblem answers, then use it to count staircase paths.
Tries and prefix search
A trie stores words by sharing the path for their common starting letters.
Union-find and connected groups
Union-find keeps track of which items are in the same group as groups are joined.
Topological sorting
A topological order puts each prerequisite before the work that requires it.
Greedy interval scheduling
A greedy strategy makes a locally chosen move, and it works only when that move can be justified.
Minimum spanning trees
A minimum spanning tree connects every vertex in a weighted undirected graph with the smallest possible total cost.
Bellman–Ford and negative edges
Bellman–Ford finds shortest paths by repeatedly checking whether any edge improves a known distance.
0/1 knapsack
Knapsack asks you to pick items with the highest total value while staying under a capacity.
Longest common subsequence
A common subsequence appears in both strings in the same order and can skip characters.
Fenwick trees and dynamic prefix sums
A Fenwick tree answers prefix-sum queries quickly while allowing individual values to change.
Segment trees and range queries
A segment tree stores summaries for ranges so a query can combine only the pieces it needs.
Monotonic stacks
A monotonic stack keeps its pending values in order so later values can resolve several at once.