Jerry the mouse is trying to reach a piece of cheese located somewhere in a maze. The maze can be represented as a graph, where:
-
Each node is labeled with a letter and a number (for example: A1, D2, F3).
-
Edges represent paths between locations in the maze.
Jerry starts at node D2 and explores the maze using Depth-First Search (DFS).
When DFS needs to choose which neighbor to visit next, Jerry must follow one consistent ordering rule. However, he is not sure which rule will lead him to the cheese the fastest.
Jerry is considering the following four DFS neighbor ordering strategies:
-
Order neighbors by the letter only, ascending (A → Z)
-
Order neighbors by the letter only, descending (Z → A)
-
Order neighbors by the number only, ascending (1 → 9)
-
Order neighbors by the number only, descending (9 → 1)
Assume that when sorting neighbors, the ignored part of the label is not considered.
The cheese is located at node J2.
Which of the following alternatives has the shortest time (number of nodes visited) and correctly describes the DFS strategy used, the order of visited nodes, and the time until Jerry finds the cheese?

Nice question, but it can be confusing. The visit order in a DFS may not constitute a path.
ResponderExcluir