Breadth first search in artificial intelligence using python (BFS)

preview_player
Показать описание
Today we are going to implement the Breadth-First Search algorithm in Python.
Breadth-First Search or also known as BFS is one of the algorithms used to traverse a graph level by level.

⌛ TIME-STAMPS ⏳
Introduction and explanation of problem: (00:00)
Solution and explanation: (03:22)
Outro and final remarks: (09:42)
⌛ TIME-STAMPS ⏳

This question may be asked in different ways but the implementation remains the same.
I have implemented BFS using a queue data structure in python.
For queue, I have used python list which works very similarly to a conventional queue.
You can also use the same code for DFS or Depth First Search only part of
the code that we need to change is we've to use our python list as a stack
instead of a queue and to do so instead of doing LIST_NAME.pop(0) we can change it to LIST_NAME.pop().

IMPLEMENTATION OF DFS:-

Code for all videos in current playlist
.
Today I'm using BFS to traverse a graph and check whether or not we can reach
a specific node from a given starting node and we'll also have a look
at path used to traverse the graph.
This algorithm is also used in Artificial Intelligence.
.
.
.
.
.
.
.
.
You can follow me on Instagram:-
You can follow me on Twitter:-
My Facebook page:-
Рекомендации по теме
Комментарии
Автор

If you're really interested in coding and learning with me please consider subscribing to my channel and here are few links to the channel home page and various playlists available on my channel:-

JKCD
Автор

Too good man. Never knew BFS and DFS was so easy to implement! please make a video on iterative DFS

tanmaytiwari
Автор

You are improving constantly, keep trying new things

zaidathar
Автор

bro i think the logic is wrong. Because, when u give start="A" and dest="C" visted will give ['A', 'B', 'C', 'D', 'E'] but ideally it should not visit D &E. (i have used your github code)

ujjawaljani
join shbcf.ru