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 10 · DSA · Built from the toolbox · with code: Python · about 18 min to read

Play it as a journeyTutor comes with a plan

Build a diff: the greedy walk

Shortest Path Traced
Shortest Path Traced · Open board

Traces the cheapest route across a small map of towns, one road at a time. This lesson draws the diff table from the last build as a map too, and finds the cheapest route across it while visiting almost none of it.

Before you start. Build a diff: the table built a diff from a table with one cell for every pair of lines: correct, but 16,000-line files already needed 2.2 GB, because the table fills every cell even when one line changed. Shortest Paths, Worked (Dijkstra, Bellman-Ford, A*) found the cheapest route across a map by always finishing the nearest unfinished town first, and Git's diff (Myers' algorithm), the case study, later in this track, shows how git answers it. Here you build that answer yourself and time it against the table.

Lesson 94 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

  • March 2006: git stops calling out to diff
  • The table, redrawn as a map of streets
  • Free rides first: the snake
  • One edit at a time, and only the furthest point on each diagonal
  • Paying for the change, not the file
  • Where the walk loses, and the one hunk that differs
  • The walk
  • The packing list, round by round
  • The race on 10,000 lines
  • Growing the files
  • The worst case
  • In an interview

Terms it explains: snake, diagonal, O(ND), Edit Distance.

Review DSA