From the course: Python Data Structures and Algorithms
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Understand the depth-first search algorithm - Python Tutorial
From the course: Python Data Structures and Algorithms
Understand the depth-first search algorithm
- [Instructor] Depth-first search is a very important algorithm with many applications in the real world. Let's first look at how depth-first search works in our maze GUI, then we will discuss some of its applications. So if we go to our GUI code in our project and we select maze_gui_explore, and I'm also going to open config so that I can choose whichever maze that I want. I think this is quite a good one to start with, a diagonal maze, so we'll stay with that for now. So then if I run my GUI, Ctrl + Shift + F10 for me, and we're in explore mode of our GUI, as we looked at earlier on. So I'm going to stick with DFS now, so that's the DFS button in red in the middle, and I can choose where I want to place my treasure. So if I place it near the bottom there, and then I press S, and off it goes looking for the treasure. And in this case, it finds it quite quickly. Now, DFS can be described as an aggressive algorithm, in the sense that it will continue down a particular path until either…
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 depth-first search algorithm3m 28s
-
(Locked)
Visualize depth-first search on a grid5m 21s
-
(Locked)
Use the Grid Tracer app2m 35s
-
(Locked)
Code a depth-first search in Python12m 10s
-
(Locked)
Challenge: Trace the path of a depth-first search44s
-
(Locked)
Solution: Trace the path of a depth-first search34s
-
(Locked)
-
-
-
-
-