Two algorithms, one input, one clock. Each page races them and explains why one wins, and when the other is the better tool.
Watch 8 sorts raceWhy halving the range beats checking one by one, and when it does not.
Watch the raceWhy BFS finds the shortest way through a maze and DFS finds the first one.
Watch the raceWhy a hash map turns Two Sum into one pass, and what sorting first buys you.
Watch the raceWhy BFS returns the fewest hops on a graph and DFS returns the first route it meets.
Watch the raceWhy a negative edge makes Dijkstra answer wrong, and what Bellman-Ford pays to be right.
See whyWhy taking the biggest coin first can cost more coins, and how a table finds the fewest.
Watch the raceWhy the best value per kilo is the wrong first pick when items cannot be split.
Watch the raceHow linear probing makes keys pay for collisions they never had.
See whyFour ways to walk one tree, and why only in-order comes out sorted.
See whyWhy the n log n sorts finish first, and when a slow sort is still the right one.
Watch the raceWhy saving each answer turns an exploding call tree into a straight line.
Watch the raceHow fast each Big-O class grows, timed on one input and one computer.
Watch the raceWhy a hash set finds a repeat in one pass, and what sorting first buys you.
Watch the raceWhy remembering the lowest price so far turns every pair into one pass.
Watch the race