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 09 · DSA · Four patterns the ladders lean on · about 16 min to read

Play it as a journeyTutor comes with a plan

When a node is a whole situation: state BFS, 0-1 BFS and Euler paths

Graphs
Graphs · Open board

: dots and the lines between them. In this lesson the dots are not places. Each dot is a whole situation, such as every wheel of a lock at once.

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

  • A lock with four wheels
  • A state: everything that can differ, written as one dot
  • State-space BFS: the shortest way through the graph you never draw
  • The word ladder: the same search with words as states
  • A line with a cost of 0 or 1
  • 0-1 BFS: a deque with two ends
  • An Euler path: use every line exactly once
  • Hierholzer: write a city down only when it is stuck
  • LC 752, Open the Lock
  • LC 127, Word Ladder
  • LC 1368, 0-1 BFS on a grid
  • LC 332, Reconstruct Itinerary
  • Edges and limits

Terms it explains: state, state-space search, wildcard bucket, deque, front, back, 0-1 BFS, Euler path, Hierholzer's algorithm, Common mistakes, LC 332, A*, adjacency list, adjacency matrix, Bellman-Ford, BFS, DAG, DFS, Dijkstra, directed vs undirected, in-degree, MST, relax an edge, sparse vs dense, topological sort, union-find, vertex/edge, weighted.

Lab

Every find walks a chain of houses up to the root. In the worst order, how long can that chain get, and what keeps it short?

Drag Cables joined to the end, then switch The habits and watch Tallest chain fall from 31 to 5.

Open The short chains

Review DSA