Is there a loop in the belts?
transcript
A parcel app has hubs and belts. Belts run both ways. Can a parcel go round in a circle? Walk the map and find out.
Start at hub zero. Mark it. Mark each hub you push. You reach hub four from hub one. Skip the belt you came by. Hub three has a belt to hub two. Hub two is already marked. That is a second way in.
Now a map with no loop. The walk marks every hub it reaches. Each belt leads to a new hub. Or it is the arrival belt. The stack runs empty. No second way in. No cycle.
Each hub is reached by one belt. That belt is its arrival belt. Any other belt to it is a second route. Two routes to one hub make a loop. Start a walk in every part of the map. A loop can hide in any part.
Mark each hub as you push it. Skip only the arrival belt. Any other marked hub is a cycle. Full breakdown in the lecture.