Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Breadth First Search Algorithm In 10 Minutes | Artificial Intelligence Tutorial | Edureka

133 views

Published on

YouTube Link: https://youtu.be/PbCl67GY1ck
** Machine Learning Engineer Masters Program: https://www.edureka.co/masters-program/machine-learning-engineer-training **
In this Edureka Session on Breadth-First Search Algorithm, we will discuss the logic behind graph traversal methods and use examples to understand the working of the Breadth-First Search algorithm.
Here’s a list of topics covered in this session:
1. Introduction To Graph Traversal
2. What is the Breadth-First Search?
3. Understanding the Breadth-First Search algorithm with an example
4. Breadth-First Search Algorithm Pseudocode
5. Applications Of Breadth-First Search

Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Breadth First Search Algorithm In 10 Minutes | Artificial Intelligence Tutorial | Edureka

  1. 1. INTRODUCTION TO GRAPH TRAVERSAL UNDERSTANDING THE BREADTH-FIRST SEARCH ALGORITHM WITH AN EXAMPLE APPLICATIONS OF BREADTH-FIRST SEARCH WHAT IS THE BREADTH-FIRST SEARCH? www.edureka.co BREADTH-FIRST SEARCH ALGORITHM PSEUDOCODE
  2. 2. INTRODUCTION TO GRAPH TRAVERSAL www.edureka.co
  3. 3. The process of visiting and exploring a graph for processing is called graph traversal. To be more specific it is all about visiting and exploring each vertex and edge in a graph such that all the vertices are explored exactly once. Introduction To Graph Traversal www.edureka.co
  4. 4. WHAT IS THE BREADTH-FIRST SEARCH? www.edureka.co
  5. 5. Breadth-First Search algorithm is a graph traversing technique, where you select a random initial node (source or root node) and start traversing the graph layer-wise in such a way that all the nodes and their respective children nodes are visited and explored. What is the Breadth-First Search Algorithm? www.edureka.co a b d c e a b d c e ExploringVisiting
  6. 6. BREADTH-FIRST SEARCH EXAMPLE www.edureka.co
  7. 7. Breadth-First Search algorithm follows a simple, level-based approach to solve a problem. Consider the above binary tree (which is a graph). Our aim is to traverse the graph by using the Breadth-First Search Algorithm. Understanding the Breadth-First Search Algorithm with an example www.edureka.co a b c d e f g What is a Queue? Binary Tree
  8. 8. A queue is an abstract data structure that follows the First-In-First-Out methodology (data inserted first will be accessed first). It is open on both ends, where one end is always used to insert data and the other is used to remove data. What is a Queue? www.edureka.co Enqueue operation Dequeue operation Enqueue operation: To insert data Dequeue operation: To remove data
  9. 9. www.edureka.co a b c d e f g Step 1: Take an Empty Queue. Queue Binary Tree
  10. 10. www.edureka.co a b c d e f g Step 2: Select a starting node (visiting a node) and insert it into the Queue. Queue Binary Tree a
  11. 11. www.edureka.co a b c d e f g Step 3: Provided that the Queue is not empty, extract the node from the Queue and insert its child nodes (exploring a node) into the Queue. Queue Binary Tree a
  12. 12. www.edureka.co a b c d e f g Step 3: Provided that the Queue is not empty, extract the node from the Queue and insert its child nodes (exploring a node) into the Queue. Queue Binary Tree bc a
  13. 13. www.edureka.co a b c d e f g Step 4: Print the extracted node. Queue Binary Tree bc Print: a a
  14. 14. www.edureka.co
  15. 15. www.edureka.co • ‘a’ is the root node: insert it into the Queue • Extract node ‘a’ and insert the child nodes of ‘a’, i.e., ‘b’ and ‘c • Print node ‘a’ • The queue is not empty and has node ‘b’ and ‘c’. Extract ‘b’ and insert the child nodes of ‘b’, i.e., node ‘d’ and ‘e’ • Repeat the steps until the queue gets empty
  16. 16. BREADTH-FIRST SEARCH ALGORITHM PSEUDOCODE www.edureka.co
  17. 17. www.edureka.co (G, s) is input, here G is the graph and s is the root node A queue ‘Q’ is created and initialized with the source node ‘s’ All child nodes of ‘s’ are marked Extract ‘s’ from queue and visit the child nodes Process all the child nodes of v Stores w (child nodes) in Q to further visit its child nodes
  18. 18. APPLICATIONS OF BREADTH-FIRST SEARCH ALGORITHM www.edureka.co
  19. 19. Breadth-first Search is a simple graph traversal method that has a surprising range of applications. Here are a few interesting ways in which Bread-First Search is being used: Applications Of Breadth-First Search Algorithm www.edureka.co Breadth First Search Applications Web crawling GPS Navigation Finding the shortest path Broadcasting
  20. 20. Copyright © 2017, edureka and/or its affiliates. All rights reserved. www.edureka.co
  21. 21. www.edureka.co

×