What procedure can we use to explore Maze BFS or DFS

I know that we can use DFS to explore the maze. But I think that we can also use BFS to explore the maze. I am a little confused because most of the books and articles I read used DFS for this problem. I find DFS complexity the best case scenario would be better compared to BFS. But the Medium and Worst Case will be the same for BFS and DFS, and therefore we prefer DFS over BFS. I am right, or I have a wrong idea.

+4
source share
3 answers

They have similar working hours , but either they can significantly outperform others in any task simply because of the order in which the cells are visited.

In terms of space utilization, BFS will on average use more memory for trees , but for more general graphs, in some cases, it can use significantly less memory.

For brush strokes, in particular (if we define a maze, since there is only one way to get to a cell from the starting point without backtracking, which basically means this tree), BFS usually uses more memory since we will need to store several paths in memory at the same time, where DFS only needs to track one path at any given time.

, , , , , .

, . , DFS .

, , BFS ( A*), , DFS ( , ).

+7

, , DFS BFS.

, BFS DFS .

, BFS, ( ..).

+9

Both must be equivalent. DFS is used more because it is a little easier to implement.

0
source

All Articles