Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Restoring Shortest Path | Practice
Breadth First Search
course content

Зміст курсу

Breadth First Search

Breadth First Search

1. What is BFS
2. Practice
3. Improve Your Code
4. Solving the Problems using BFS

Restoring Shortest Path

BFS searching shortest path

That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.

To do that, you have to know for each node where did it come from. So, let's add list pred that contains predcessor for i node. At the beginning, pred contains only -1.

Завдання

Modify bfs(start, end) so it returns a list of vertices between start and end nodes (both inclusive). If there is no path, return an empty list.

Do not forget to keep the path.

Завдання

Modify bfs(start, end) so it returns a list of vertices between start and end nodes (both inclusive). If there is no path, return an empty list.

Do not forget to keep the path.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 4
toggle bottom row

Restoring Shortest Path

BFS searching shortest path

That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.

To do that, you have to know for each node where did it come from. So, let's add list pred that contains predcessor for i node. At the beginning, pred contains only -1.

Завдання

Modify bfs(start, end) so it returns a list of vertices between start and end nodes (both inclusive). If there is no path, return an empty list.

Do not forget to keep the path.

Завдання

Modify bfs(start, end) so it returns a list of vertices between start and end nodes (both inclusive). If there is no path, return an empty list.

Do not forget to keep the path.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 4
toggle bottom row

Restoring Shortest Path

BFS searching shortest path

That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.

To do that, you have to know for each node where did it come from. So, let's add list pred that contains predcessor for i node. At the beginning, pred contains only -1.

Завдання

Modify bfs(start, end) so it returns a list of vertices between start and end nodes (both inclusive). If there is no path, return an empty list.

Do not forget to keep the path.

Завдання

Modify bfs(start, end) so it returns a list of vertices between start and end nodes (both inclusive). If there is no path, return an empty list.

Do not forget to keep the path.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

BFS searching shortest path

That was hard! But now let's implement a method to find the shortest path between two vertices, not only length.

To do that, you have to know for each node where did it come from. So, let's add list pred that contains predcessor for i node. At the beginning, pred contains only -1.

Завдання

Modify bfs(start, end) so it returns a list of vertices between start and end nodes (both inclusive). If there is no path, return an empty list.

Do not forget to keep the path.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 4
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt