SlideShare a Scribd company logo
1 of 51
BREADTH FIRST SEARCH
Breadth First Search


-
A                B             C    D




    E            F             G    H




I




         front

                       FIFO Queue
Breadth First Search


           -
           A                           B         C      D




                      E                F         G      H




           I




enqueue source node        front   A
                                           FIFO Queue
Breadth First Search


           -
           A                           B         C      D




                      E                F         G      H




           I




dequeue next vertex        front   A
                                           FIFO Queue
Breadth First Search


           -
           A                        B             C    D




                       E            F             G    H




           I




visit neighbors of A        front

                                          FIFO Queue
Breadth First Search


           -
           A                        B             C    D




                       E            F             G    H




           I




visit neighbors of A        front

                                          FIFO Queue
Breadth First Search


       -                        A
       A                        B         C      D




               E                F         G      H




       I




B discovered        front   B
                                    FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H




           I




visit neighbors of A        front   B
                                            FIFO Queue
Breadth First Search


       -                     A
        A                    B            C    D




               E             F            G    H




        I

       A



I discovered        front   B I
                                  FIFO Queue
Breadth First Search


         -                      A
         A                      B            C    D




                  E             F            G    H




         I

         A



finished with A        front   B I
                                     FIFO Queue
Breadth First Search


           -                        A
           A                        B            C    D




                      E             F            G    H




           I

           A



dequeue next vertex        front   B I
                                         FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H




            I

           A



visit neighbors of B        front   I
                                            FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H




            I

           A



visit neighbors of B        front   I
                                            FIFO Queue
Breadth First Search


       -                     A
       A                     B            C    D




               E             F            G    H

                             B


       I

       A



F discovered        front   I F
                                  FIFO Queue
Breadth First Search


           -                         A
           A                         B            C    D




                       E             F            G    H

                                     B


            I

           A



visit neighbors of B        front   I F
                                          FIFO Queue
Breadth First Search


           -                         A
           A                         B            C    D




                       E             F            G    H

                                     B


           I

           A



A already discovered        front   I F
                                          FIFO Queue
Breadth First Search


         -                      A
         A                      B            C    D




                  E             F            G    H

                                B


         I

         A



finished with B        front   I F
                                     FIFO Queue
Breadth First Search


           -                        A
           A                        B            C    D




                      E             F            G    H

                                    B


           I

           A



dequeue next vertex        front   I F
                                         FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H

                                        B


            I

           A



visit neighbors of I        front   F
                                            FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H

                                        B


            I

           A



visit neighbors of I        front   F
                                            FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H

                                        B


           I

           A



A already discovered        front   F
                                            FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H

                                        B


            I

           A



visit neighbors of I        front   F
                                            FIFO Queue
Breadth First Search


       -                     A
       A                     B            C    D




               E             F            G    H

               I             B


        I

       A



E discovered        front   F E
                                  FIFO Queue
Breadth First Search


           -                         A
           A                         B            C    D




                       E             F            G    H

                       I             B


            I

           A



visit neighbors of I        front   F E
                                          FIFO Queue
Breadth First Search


           -                         A
           A                         B            C    D




                       E             F            G    H

                       I             B


           I

           A



F already discovered        front   F E
                                          FIFO Queue
Breadth First Search


      -                    A
      A                    B            C    D




             E             F            G    H

             I             B


      I

      A



I finished        front   F E
                                FIFO Queue
Breadth First Search


           -                        A
           A                        B            C    D




                      E             F            G    H

                      I             B


           I

           A



dequeue next vertex        front   F E
                                         FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H

                       I                B


            I

           A



visit neighbors of F        front   E
                                            FIFO Queue
Breadth First Search


       -                     A
       A                     B            C    D




               E             F            G    H

               I             B            F


       I

       A



G discovered        front   E G
                                  FIFO Queue
Breadth First Search


      -                    A
      A                    B            C    D




             E             F            G    H

             I             B            F


      I

      A



F finished        front   E G
                                FIFO Queue
Breadth First Search


           -                        A
           A                        B            C    D




                      E             F            G    H

                      I             B            F


           I

           A



dequeue next vertex        front   E G
                                         FIFO Queue
Breadth First Search


           -                            A
           A                            B         C      D




                       E                F         G      H

                       I                B         F


            I

           A



visit neighbors of E        front   G
                                            FIFO Queue
Breadth First Search


      -                       A
      A                       B         C      D




             E                F         G      H

             I                B         F


      I

      A



E finished        front   G
                                  FIFO Queue
Breadth First Search


           -                           A
           A                           B         C      D




                      E                F         G      H

                      I                B         F


           I

           A



dequeue next vertex        front   G
                                           FIFO Queue
Breadth First Search


           -                        A
           A                        B             C    D




                       E            F             G    H

                       I            B             F


            I

           A



visit neighbors of G        front

                                          FIFO Queue
Breadth First Search


       -                        A         G
       A                        B         C      D




               E                F         G      H

               I                B         F


       I

       A



C discovered        front   C
                                    FIFO Queue
Breadth First Search


           -                            A         G
           A                            B         C      D




                       E                F         G      H

                       I                B         F


            I

           A



visit neighbors of G        front   C
                                            FIFO Queue
Breadth First Search


       -                     A            G
       A                     B            C    D




               E             F            G    H

               I             B            F    G


       I

       A



H discovered        front   C H
                                  FIFO Queue
Breadth First Search


      -                    A            G
      A                    B            C    D




             E             F            G    H

             I             B            F    G


      I

      A



G finished        front   C H
                                FIFO Queue
Breadth First Search


           -                        A            G
           A                        B            C    D




                      E             F            G    H

                      I             B            F    G


           I

           A



dequeue next vertex        front   C H
                                         FIFO Queue
Breadth First Search


           -                            A         G
           A                            B         C      D




                       E                F         G      H

                       I                B         F      G


            I

           A



visit neighbors of C        front   H
                                            FIFO Queue
Breadth First Search


       -                     A            G    C
       A                     B            C    D




               E             F            G    H

               I             B            F    G


       I

       A



D discovered        front   H D
                                  FIFO Queue
Breadth First Search


      -                    A            G    C
      A                    B            C    D




             E             F            G    H

             I             B            F    G


      I

      A



C finished        front   H D
                                FIFO Queue
Breadth First Search


         -                      A            G    C
         A                      B            C    D




                  E             F            G    H

                  I             B            F    G


         I

         A



get next vertex        front   H D
                                     FIFO Queue
Breadth First Search


           -                            A         G      C
           A                            B         C      D




                       E                F         G      H

                       I                B         F      G


           I

           A



visit neighbors of H        front   D
                                            FIFO Queue
Breadth First Search


      -                       A         G      C
      A                       B         C      D




             E                F         G      H

             I                B         F      G


      I

      A



finished H        front   D
                                  FIFO Queue
Breadth First Search


           -                           A         G      C
           A                           B         C      D




                      E                F         G      H

                      I                B         F      G


           I

           A



dequeue next vertex        front   D
                                           FIFO Queue
Breadth First Search


           -                        A             G    C
           A                        B             C    D




                       E            F             G    H

                       I            B             F    G


           I

           A



visit neighbors of D        front

                                          FIFO Queue
Breadth First Search


      -                   A             G    C
      A                   B             C    D




             E            F             G    H

             I            B             F    G


      I

      A



D finished        front

                                FIFO Queue
Breadth First Search


           -                       A             G    C
           A                       B             C    D




                      E            F             G    H

                      I            B             F    G


           I

           A



dequeue next vertex        front

                                         FIFO Queue
Breadth First Search


   -                A             G    C
   A                B             C    D




       E            F             G    H

       I            B             F    G


   I

   A



STOP        front

                          FIFO Queue

More Related Content

Viewers also liked

A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare
 

Viewers also liked (8)

Graph in data structure
Graph in data structureGraph in data structure
Graph in data structure
 
Graphs ppt
Graphs pptGraphs ppt
Graphs ppt
 
White House State of the Union 2016 - Enhanced Graphics
White House State of the Union 2016 - Enhanced GraphicsWhite House State of the Union 2016 - Enhanced Graphics
White House State of the Union 2016 - Enhanced Graphics
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShare
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Recently uploaded (20)

Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Bfs