From the course: Python Data Structures and Algorithms
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Understand the breadth-first search algorithm - Python Tutorial
From the course: Python Data Structures and Algorithms
Understand the breadth-first search algorithm
- [Instructor] Breadth-first search is another very important algorithm with many real world applications. Its implementation is based on the queue data structure, which we've just studied. Let's look now at how breadth-first search works in our maze GUI. So if you go to your project and you open up maze_gui_explore.py and also config. So in config, we're going to uncomment this MAZE_FILE equals gui_mazes/walled_garden_20x20.txt, and there's a reason why we're using that specific one. And then go to your maze_gui_explore.py file and run it. You can either use the Run menu, but I use Ctrl + Shift + F10. And this is what we have, made that full screen. So the reason I've chosen this maze is because the opponent is in the middle, and you'll see that with breadth-first search, having it in the middle makes the pattern of how it behaves a bit more clear. So if I select a cell to place my treasure in, like so, and I press S, that's DFS, okay, just to remind us. But that's not what we're…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Understand the breadth-first search algorithm3m 1s
-
(Locked)
Visualize breadth-first search in a grid5m 10s
-
(Locked)
Code a breadth-first search in Python6m 39s
-
(Locked)
Challenge: Trace the path of a breadth-first search30s
-
(Locked)
Solution: Trace the path of a breadth-first search37s
-
(Locked)
-
-
-