Write, then reverse
transcript
A music app logs every handoff. Each handoff happened exactly once. Replay the session from the log. A greedy walk gets stuck. Here is the fix.
Walk until a track has no handoff left. Write that track down. Go back and continue the walk.
Track one is stuck. Write it first. Back at zero. Go to two, then back. Zero is written, then two, then zero. The written list is one, zero, two, zero.
A dead end has no way out. So it must end the session. It is written first, so it ends up last.
The list is the session backwards. Reverse it. Zero, two, zero, one is the session.
Nine handoffs have 362,880 orders. This walk needs only nineteen steps.
A session can return to a node. But each link is used once. Take them from a sorted list.
Write a node when it is stuck. Then reverse the list. Take each link once. Full breakdown in the lecture.