Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
How to Search | What is BFS
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

How to Search

Breadth First Search (BFS), or Traversal is an algorithm for searching on graph data structure for a node. This algorithm is useful, for example, for searching the shortest path between two nodes, and you can see how it works on example:

The main approach: for the current node, traverse all neighbors that haven’t been visited yet, and do BFS for them. Algorithm is a technique to do graph traversal.

For tracking path, use queue data structure. When you are visiting node (this is a first element in the queue), push all non-visited neighbors of it to the queue, and remove the current node. This way, you’ll traverse all the neighbors one by one.

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

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

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

How to Search

Breadth First Search (BFS), or Traversal is an algorithm for searching on graph data structure for a node. This algorithm is useful, for example, for searching the shortest path between two nodes, and you can see how it works on example:

The main approach: for the current node, traverse all neighbors that haven’t been visited yet, and do BFS for them. Algorithm is a technique to do graph traversal.

For tracking path, use queue data structure. When you are visiting node (this is a first element in the queue), push all non-visited neighbors of it to the queue, and remove the current node. This way, you’ll traverse all the neighbors one by one.

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

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

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

How to Search

Breadth First Search (BFS), or Traversal is an algorithm for searching on graph data structure for a node. This algorithm is useful, for example, for searching the shortest path between two nodes, and you can see how it works on example:

The main approach: for the current node, traverse all neighbors that haven’t been visited yet, and do BFS for them. Algorithm is a technique to do graph traversal.

For tracking path, use queue data structure. When you are visiting node (this is a first element in the queue), push all non-visited neighbors of it to the queue, and remove the current node. This way, you’ll traverse all the neighbors one by one.

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

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

Breadth First Search (BFS), or Traversal is an algorithm for searching on graph data structure for a node. This algorithm is useful, for example, for searching the shortest path between two nodes, and you can see how it works on example:

The main approach: for the current node, traverse all neighbors that haven’t been visited yet, and do BFS for them. Algorithm is a technique to do graph traversal.

For tracking path, use queue data structure. When you are visiting node (this is a first element in the queue), push all non-visited neighbors of it to the queue, and remove the current node. This way, you’ll traverse all the neighbors one by one.

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