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.
Solution: Trace the path of a breadth-first search - Python Tutorial
From the course: Python Data Structures and Algorithms
Solution: Trace the path of a breadth-first search
(upbeat music) - [Instructor] Here's a solution to the BFS challenge then. So this is the path the algorithm produces for the given maze, assuming you used exactly the same implementation that we have been using so far. And that includes the order on which we own QR elements. So we go up, right, down, left. So the path you should have got is (0,0), (0,1), (1,1) (1,2), (2,2), (3,2), (3,3), as shown on the slide. If you got a different answer, then go back and see what you did differently and see if when you apply the algorithm correctly, you get the same result as I did.
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)
-
-
-