Reader small image

You're reading from  Hands-On Artificial Intelligence for Search

Product typeBook
Published inAug 2018
Reading LevelIntermediate
PublisherPackt
ISBN-139781789611151
Edition1st Edition
Languages
Right arrow
Author (1)
Devangini Patel
Devangini Patel
author image
Devangini Patel

Devangini Patel is a PhD student at the National University of Singapore, Singapore. Her research interests include deep learning, computer vision, machine learning, and artificial intelligence. She has completed a master's in artificial intelligence at the University of Southampton, UK. She has over 5 years, experience in the field of AI and has worked on various industrial and research projects in AI, including facial expression analysis, robotics, virtual try-on, object recognition and detection, and advertisement ranking.
Read more about Devangini Patel

Right arrow

The BFS algorithm

In this section, we'll look at the flow of the BFS algorithm, how a queue is used, and how graph data affects the algorithm. The flow of the BFS algorithm is similar to that of DFS, but instead of using a stack data structure, a queue data structure is used.

A flowchart of the BFS algorithm can be illustrated as follows:

Figure 13
  1. We initially create a root node with an initial state, and add it to a queue and tree.
  2. A node is dequeued from the queue, and we check whether it has the goal state. If it does, we end our search. If it doesn't, we find the child nodes of the dequeued node and add them to the queue entry.
  3. This process is repeated until we either find the goal state or have exhausted all of the nodes in our search tree.
  4. Since our connection data is in a graph structure, we have to check whether each node has been visited before.
  5. So, we add...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-On Artificial Intelligence for Search
Published in: Aug 2018Publisher: PacktISBN-13: 9781789611151

Author (1)

author image
Devangini Patel

Devangini Patel is a PhD student at the National University of Singapore, Singapore. Her research interests include deep learning, computer vision, machine learning, and artificial intelligence. She has completed a master's in artificial intelligence at the University of Southampton, UK. She has over 5 years, experience in the field of AI and has worked on various industrial and research projects in AI, including facial expression analysis, robotics, virtual try-on, object recognition and detection, and advertisement ranking.
Read more about Devangini Patel