Chapter 5
■
traversal: the skeleton key of algorithmiCs
95
Notice that there are three kinds of rooms: the ones you’ve actually visited (those with tracks through them),
those you know about because you’ve seen their doors, and those you don’t know about yet (darkened). The unknown
rooms are (of course) separated from the visited rooms by a frontier of known but unvisited rooms, just like in any
kind of traversal. Listing 5-1 gives a simple implementation of this general traversal strategy (with the comments
referring to graphs rather than dungeons).
3
Do'stlaringiz bilan baham: