Breadth-First Search: Difference between revisions

From Wiki :-)
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
Unlike Depth-First Search, it looks for the neighbours node first before going for the children.
Unlike Depth-First Search, it looks for the neighbours node first before going for the children.


The algorithm uses queues to get the list of children of the node's neighbours to visit then is the correct order.
The algorithm uses queues to get the list of children of the node's neighbours to visit them is the correct order.
 
BFS is generally better if we want to find the shortest path in a graph.
 
== Resources ==
{| class="wikitable"
!
|-
|https://en.wikipedia.org/wiki/Breadth-first_search
|}

Latest revision as of 04:42, 3 October 2020

The Breadth-First Search is an iterative algorithm that finds if there is a path from one node to another.

Unlike Depth-First Search, it looks for the neighbours node first before going for the children.

The algorithm uses queues to get the list of children of the node's neighbours to visit them is the correct order.

BFS is generally better if we want to find the shortest path in a graph.

Resources

https://en.wikipedia.org/wiki/Breadth-first_search