Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 03 · DSA · Worked, and deeper · about 22 min to read

Play it as a journeyTutor comes with a plan

Close enough on purpose: approximation algorithms

When Problems Are Hard
When Problems Are Hard · Open board

Shows the cliff at the end of the board. Past it, exact answers stop finishing.

Before you start. Complexity Theory (when problems are hard) showed that some problems are NP-hard, which means nobody knows a fast way to find the best answer. It ended with a list of moves: approximate, use a heuristic, prune, or restrict the input. This lesson builds the first move properly. Algorithm Design Patterns gave you greedy, which means grabbing the best-looking choice right now and never going back. Graphs (BFS, DFS, Dijkstra, topological sort) gave you graphs and spanning trees, which we use below.

Lesson 26 of 96 in DSA

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 20 deliveries, and a computer that needs 19 years
  • The approximation ratio: how far from best you are allowed to be
  • Vertex cover: watch every road from one end
  • Set cover: pick the biggest, again and again
  • The triangle inequality: why a detour is never shorter
  • Spanning tree: the shortest wiring that touches every city
  • Double the tree, then skip repeats
  • Vertex cover, run
  • Greedy set cover, run
  • Double tree, run
  • Edge cases and the state of the art
  • LeetCode 1584, Min Cost to Connect All Points (free, isPaidOnly false, checked 2026-11-28)
  • LeetCode 1024, Video Stitching (free, isPaidOnly false, checked 2026-11-28)

Terms it explains: approximation algorithm, approximation ratio, Vertex cover, maximal matching, set cover, triangle inequality, spanning tree, minimum spanning tree, Common mistakes, Without the triangle inequality, Christofides (1976).

Lab

Ten cities, and you can check every possible route. Eleven, and you cannot. So what do you ship for the eleventh?

Set Cities on the map to 10, read The gap, then add one city and watch that number disappear.

Open The cliff at n = 11

Review DSA