For our maze, we can use BFS or DFS to find a path if such a path exists. If a path exists, it is guaranteed that BFS/DFS will find a solution. With BFS, it is even guaranteed that we will get the shortest path. We interpret the whole maze as a graph where each (walkable) cell is a node in the graph. We then want to traverse this graph from a start Node to an end Node. We also keep track of the nodes that we have already visited. This search process then yields a tree
the maze itself is a graph (potentially with cycles), and it’s the search process (with visited-marking and parent pointers) that “yields a tree.”