Algorithms

From sorting to dynamic programming β€” step-by-step guides with interactive examples.

Complexity & Analysis
Sorting
Searching & Selection
Divide & Conquer
Greedy Algorithms
Dynamic Programming
DP Pattern
Never solve the same puzzle piece twice β€” write it down and look it up next time
β†’
Memoization vs Tabulation
Top-down is calling a friend who calls a friend. Bottom-up is filling a spreadsheet row by row.
β†’
1D DP
Build the answer one step at a time β€” just like climbing stairs
β†’
0/1 Knapsack
Pack a suitcase for maximum value β€” each item is all-or-nothing
β†’
Unbounded Knapsack
Take as many of each item as you want β€” the vending machine version
β†’
Longest Common Subsequence
Find the longest story two sequences share β€” skipping is allowed
β†’
Longest Increasing Subsequence
Find the longest staircase hidden inside a jumbled sequence
β†’
Edit Distance
How many typo-fixes does it take to turn one word into another?
β†’
Matrix Chain Multiplication
The order you multiply matrices matters enormously β€” find the cheapest order
β†’
DP on Intervals
Solve tiny sections first, then merge them into bigger ones
β†’
DP on Trees
Each node's answer depends on its children β€” compute bottom-up
β†’
Bitmask DP
Track every possible subset of choices in a single integer
β†’
Digit DP
Count numbers with digit constraints β€” without checking each one
β†’
Graph Algorithms
BFS & DFS Revisited
Two ways to explore a graph β€” level by level, or all the way in
β†’
Topological Sort
Order tasks by their dependencies β€” no chicken-before-egg
β†’
Dijkstra's Algorithm
Always extend the cheapest road first β€” GPS navigation for graphs
β†’
Bellman-Ford & SPFA
Handle negative weights and catch negative cycles
β†’
Floyd-Warshall
Find shortest paths between every pair of cities in one sweep
β†’
A* Search
Smarter than Dijkstra β€” use a hint to head in the right direction
β†’
Tarjan's Algorithm
Find all tightly-knit groups in a directed graph in one pass
β†’
Kosaraju's Algorithm
Find mutual-follow groups with two clever graph walks
β†’
Eulerian Path & Circuit
Can you cross every bridge exactly once? Euler answered this in 1736
β†’
Hamiltonian Path
Visit every house exactly once β€” far harder than every bridge
β†’
Network Flow
String Algorithms
Randomized Algorithms
Advanced Topics