際際滷

際際滷Share a Scribd company logo
BFS
Breadth-first search
 Breadth-first search (BFS) is an algorithm for traversing
or searching tree or graph data structures.
 It starts at the tree root (or some arbitrary node of a
graph, sometimes referred to as a search key), and
explores all of the neighbor nodes at the present depth
prior to moving on to the nodes at the next depth level.
 It is implemented using a queue(FIFO).
 BFS traverses the tree shallowest node first, it would
always pick the shallower branch until it reaches the
solution (or it runs out of nodes, and goes to the next
branch).
Algorithm
3
 Declare a queue and insert the starting vertex.
 Initialize a visited array and mark the starting vertex as
visited.
 Follow the below process till the queue becomes empty:
 Remove the first vertex of the queue.
 Mark that vertex as visited.
 Insert all the unvisited neighbors of the vertex into the
queue.
Consider the Following Example
Example-1
Breadth First Search- STEP1
 Choose the Starting Vertex as A
 VISIT A
 Insert A into the Queue
A
QUEUE:
Breadth First Search- STEP2
Visit all adjacent vertices of A which
are not visited(Here: D,E,B)
Insert newly visited vertices into the queue
and delete A from the Queue
D E B
QUEUE:
RESULT: A
Breadth First Search- STEP3
Visit all adjacent vertices of D which
are not visited (No Vertex)
Delete D from the Queue
E B
QUEUE:
RESULT: A D
Breadth First Search- STEP4
 Visit all adjacent vertices of E which are not visited(Here
C, F)
 Insert newly visited vertices into the queue and delete E
from the Queue
B C F
QUEUE:
RESULT: A D E
Breadth First Search- STEP5
Visit all adjacent vertices of B which
are not visited(No Vertex)
Delete B from the Queue
C F
QUEUE:
RESULT: A D E B
Breadth First Search- STEP6
 Visit all adjacent vertices of C which are
not visited(Here G)
 Insert newly visited vertices into the queue and delete
C from the Queue
F G
QUEUE:
RESULT: A D E B C
Breadth First Search- STEP7
 Visit all adjacent vertices of F which are not
visited(Here No Vertex)
 Delete F from the Queue
G
QUEUE:
RESULT: A D E B C F
Breadth First Search- STEP8
Visit all adjacent vertices of G which are
not visited(Here No Vertex)
Delete G from the Queue
QUEUE:
Queue Empty, End the
Process
RESULT: A D E B C F G
BFS Traversal - Result
AD EBCF G
14
Advantages
 BFS will provide a solution if any solution exists.
 If there are more than one solution for a given problem, then BFS
will provide minimum solution which requires the least number of
steps.
Disadvantage
 It requires lot of memory since each level of the tree must be saved
into memory to expand the next level.
 BFS needs lot of time if the solution is far a way from the root.
Example
15
 BFS Output will be ?
 Output of BFS : 1 2 3 4 5 6 7 8 9 10 11 12
16
17
Algorithm of BFS
18
19
Time complexity: Equivalent to the number of nodes
traversed in BFS until the shallowest solution.
T(n) = 1 + n^2 + n^3 + ... + n^s = O(n^s)
 s = the depth of the shallowest solution.
 n^i = number of nodes in level i.
Space complexity: Equivalent to how large can the fringe
get.
S(n) = O(n^s)
20
 Completeness: BFS is complete, meaning for a given search
tree, BFS will come up with a solution if it exists.
 Optimality: BFS is optimal as long as the costs of all edges
are equal.
21
22
23

More Related Content

Similar to Breadth First Search with example and solutions (20)

AI-search-metodsandeverythingelsenot.ppt
AI-search-metodsandeverythingelsenot.pptAI-search-metodsandeverythingelsenot.ppt
AI-search-metodsandeverythingelsenot.ppt
s0618614
Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4Final slide4 (bsc csit) chapter 4
Final slide4 (bsc csit) chapter 4
Subash Chandra Pakhrin
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
gagaco5776
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptxRPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RahulkumarTivarekar1
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
iftakhar8
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
graphtraversals.pdf
graphtraversals.pdfgraphtraversals.pdf
graphtraversals.pdf
SeethaDinesh
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
MUZAMILALI48
Trees second part in data structures with examples
Trees second part in data structures with examplesTrees second part in data structures with examples
Trees second part in data structures with examples
rupanaveen24
Depth first Search.pptx
Depth first Search.pptxDepth first Search.pptx
Depth first Search.pptx
AleezaShakeel3
uniformed (also called blind search algo)
uniformed (also called blind search algo)uniformed (also called blind search algo)
uniformed (also called blind search algo)
ssuser2a76b5
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
mmpnair0
Artificial Intelligence Problem Slaving PPT
Artificial Intelligence  Problem Slaving PPTArtificial Intelligence  Problem Slaving PPT
Artificial Intelligence Problem Slaving PPT
vipulkondekar
BFS,DFS,Depth bound,Beam search,Iterative.pptx
BFS,DFS,Depth bound,Beam search,Iterative.pptxBFS,DFS,Depth bound,Beam search,Iterative.pptx
BFS,DFS,Depth bound,Beam search,Iterative.pptx
PriyadharshiniG41
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
SigSegVSquad
Presentation on the artificial intelligenc
Presentation on the artificial intelligencPresentation on the artificial intelligenc
Presentation on the artificial intelligenc
PriyadharshiniG41
2.5 bfs & dfs 02
2.5 bfs & dfs 022.5 bfs & dfs 02
2.5 bfs & dfs 02
Krish_ver2
Branch and Bound.pptx
Branch and Bound.pptxBranch and Bound.pptx
Branch and Bound.pptx
JoshipavanEdduluru1
3-uninformed-search.ppt
3-uninformed-search.ppt3-uninformed-search.ppt
3-uninformed-search.ppt
ABINASHACHERJEE1
Bfs present
Bfs presentBfs present
Bfs present
minhaz uddin
AI-search-metodsandeverythingelsenot.ppt
AI-search-metodsandeverythingelsenot.pptAI-search-metodsandeverythingelsenot.ppt
AI-search-metodsandeverythingelsenot.ppt
s0618614
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
6CS4_AI_Unit-1.pptx helo to leairn dsa in a eay
gagaco5776
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptxRPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RPT_AI_03_PartB_UNINFORMED_FINAL.pptx
RahulkumarTivarekar1
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
iftakhar8
Graph traversals in Data Structures
Graph traversals in Data StructuresGraph traversals in Data Structures
Graph traversals in Data Structures
Anandhasilambarasan D
graphtraversals.pdf
graphtraversals.pdfgraphtraversals.pdf
graphtraversals.pdf
SeethaDinesh
uninformed search part 1.pptx
uninformed search part 1.pptxuninformed search part 1.pptx
uninformed search part 1.pptx
MUZAMILALI48
Trees second part in data structures with examples
Trees second part in data structures with examplesTrees second part in data structures with examples
Trees second part in data structures with examples
rupanaveen24
Depth first Search.pptx
Depth first Search.pptxDepth first Search.pptx
Depth first Search.pptx
AleezaShakeel3
uniformed (also called blind search algo)
uniformed (also called blind search algo)uniformed (also called blind search algo)
uniformed (also called blind search algo)
ssuser2a76b5
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
2012wq171-03-UninformedSeknlk ;lm,l;mk;arch.ppt
mmpnair0
Artificial Intelligence Problem Slaving PPT
Artificial Intelligence  Problem Slaving PPTArtificial Intelligence  Problem Slaving PPT
Artificial Intelligence Problem Slaving PPT
vipulkondekar
BFS,DFS,Depth bound,Beam search,Iterative.pptx
BFS,DFS,Depth bound,Beam search,Iterative.pptxBFS,DFS,Depth bound,Beam search,Iterative.pptx
BFS,DFS,Depth bound,Beam search,Iterative.pptx
PriyadharshiniG41
Analysis of Pathfinding Algorithms
Analysis of Pathfinding AlgorithmsAnalysis of Pathfinding Algorithms
Analysis of Pathfinding Algorithms
SigSegVSquad
Presentation on the artificial intelligenc
Presentation on the artificial intelligencPresentation on the artificial intelligenc
Presentation on the artificial intelligenc
PriyadharshiniG41
2.5 bfs & dfs 02
2.5 bfs & dfs 022.5 bfs & dfs 02
2.5 bfs & dfs 02
Krish_ver2
3-uninformed-search.ppt
3-uninformed-search.ppt3-uninformed-search.ppt
3-uninformed-search.ppt
ABINASHACHERJEE1

Recently uploaded (20)

windrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptxwindrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptx
nukeshpandey5678
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptxUHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
arivazhaganrajangam
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
NIT SILCHAR
PCB Design - Top Factors Related to Data Routing and Layout
PCB Design - Top Factors Related to Data Routing and LayoutPCB Design - Top Factors Related to Data Routing and Layout
PCB Design - Top Factors Related to Data Routing and Layout
Epec Engineered Technologies
BCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdfBCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdf
VENKATESHBHAT25
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Priyanka Dange
OFFICE AUTOMATION USING ESP32 AND ESP RAINMAKER
OFFICE AUTOMATION USING ESP32 AND ESP RAINMAKEROFFICE AUTOMATION USING ESP32 AND ESP RAINMAKER
OFFICE AUTOMATION USING ESP32 AND ESP RAINMAKER
AdityaSK5
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
Intro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching schemeIntro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching scheme
Priyanka Dange
22PCOAM16 _ML_ Unit 2 Full unit notes.pdf
22PCOAM16 _ML_ Unit 2 Full unit notes.pdf22PCOAM16 _ML_ Unit 2 Full unit notes.pdf
22PCOAM16 _ML_ Unit 2 Full unit notes.pdf
Guru Nanak Technical Institutions
CS50x: CS50's Introduction to Computer Science.pdf
CS50x: CS50's Introduction to Computer Science.pdfCS50x: CS50's Introduction to Computer Science.pdf
CS50x: CS50's Introduction to Computer Science.pdf
Naiyan Noor
Industry 4.0: Transforming Modern Manufacturing and Beyond
Industry 4.0: Transforming Modern Manufacturing and BeyondIndustry 4.0: Transforming Modern Manufacturing and Beyond
Industry 4.0: Transforming Modern Manufacturing and Beyond
GtxDriver
Final Round of technical quiz on Chandrayaan
Final Round of technical quiz on ChandrayaanFinal Round of technical quiz on Chandrayaan
Final Round of technical quiz on Chandrayaan
kamesh sonti
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptxUHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
arivazhaganrajangam
Mastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdfMastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdf
Brion Mario
Transformer ppt for micro-teaching (2).pptx
Transformer ppt for micro-teaching (2).pptxTransformer ppt for micro-teaching (2).pptx
Transformer ppt for micro-teaching (2).pptx
GetahunShankoKefeni
Mix Design of M40 Concrete & Application of NDT.pptx
Mix Design of M40 Concrete & Application of NDT.pptxMix Design of M40 Concrete & Application of NDT.pptx
Mix Design of M40 Concrete & Application of NDT.pptx
narayan311979
BSS_1_E1.2_ElectromobilityElectromobility.pdf
BSS_1_E1.2_ElectromobilityElectromobility.pdfBSS_1_E1.2_ElectromobilityElectromobility.pdf
BSS_1_E1.2_ElectromobilityElectromobility.pdf
jungdan064
22PCOAM16 ML UNIT 2 NOTES & QB QUESTION WITH ANSWERS
22PCOAM16 ML UNIT 2 NOTES & QB QUESTION WITH ANSWERS22PCOAM16 ML UNIT 2 NOTES & QB QUESTION WITH ANSWERS
22PCOAM16 ML UNIT 2 NOTES & QB QUESTION WITH ANSWERS
Guru Nanak Technical Institutions
windrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptxwindrose1.ppt for seminar of civil .pptx
windrose1.ppt for seminar of civil .pptx
nukeshpandey5678
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANEAirport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Airport Components Part1 ppt.pptx-Site layout,RUNWAY,TAXIWAY,TAXILANE
Priyanka Dange
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptxUHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
UHV UNIT-3 HARMONY IN THE FAMILY AND SOCIETY.pptx
arivazhaganrajangam
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
Self-Compacting Concrete: Composition, Properties, and Applications in Modern...
NIT SILCHAR
PCB Design - Top Factors Related to Data Routing and Layout
PCB Design - Top Factors Related to Data Routing and LayoutPCB Design - Top Factors Related to Data Routing and Layout
PCB Design - Top Factors Related to Data Routing and Layout
Epec Engineered Technologies
BCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdfBCS401 ADA First IA Test Question Bank.pdf
BCS401 ADA First IA Test Question Bank.pdf
VENKATESHBHAT25
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Intro of Airport Engg..pptx-Definition of airport engineering and airport pla...
Priyanka Dange
OFFICE AUTOMATION USING ESP32 AND ESP RAINMAKER
OFFICE AUTOMATION USING ESP32 AND ESP RAINMAKEROFFICE AUTOMATION USING ESP32 AND ESP RAINMAKER
OFFICE AUTOMATION USING ESP32 AND ESP RAINMAKER
AdityaSK5
Kamal 2, new features and practical examples
Kamal 2, new features and practical examplesKamal 2, new features and practical examples
Kamal 2, new features and practical examples
Igor Aleksandrov
Intro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching schemeIntro PPT SY_HONORS.pptx- Teaching scheme
Intro PPT SY_HONORS.pptx- Teaching scheme
Priyanka Dange
CS50x: CS50's Introduction to Computer Science.pdf
CS50x: CS50's Introduction to Computer Science.pdfCS50x: CS50's Introduction to Computer Science.pdf
CS50x: CS50's Introduction to Computer Science.pdf
Naiyan Noor
Industry 4.0: Transforming Modern Manufacturing and Beyond
Industry 4.0: Transforming Modern Manufacturing and BeyondIndustry 4.0: Transforming Modern Manufacturing and Beyond
Industry 4.0: Transforming Modern Manufacturing and Beyond
GtxDriver
Final Round of technical quiz on Chandrayaan
Final Round of technical quiz on ChandrayaanFinal Round of technical quiz on Chandrayaan
Final Round of technical quiz on Chandrayaan
kamesh sonti
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptxUHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
UHV Unit - 4 HARMONY IN THE NATURE AND EXISTENCE.pptx
arivazhaganrajangam
Mastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdfMastering Secure Login Mechanisms for React Apps.pdf
Mastering Secure Login Mechanisms for React Apps.pdf
Brion Mario
Transformer ppt for micro-teaching (2).pptx
Transformer ppt for micro-teaching (2).pptxTransformer ppt for micro-teaching (2).pptx
Transformer ppt for micro-teaching (2).pptx
GetahunShankoKefeni
Mix Design of M40 Concrete & Application of NDT.pptx
Mix Design of M40 Concrete & Application of NDT.pptxMix Design of M40 Concrete & Application of NDT.pptx
Mix Design of M40 Concrete & Application of NDT.pptx
narayan311979
BSS_1_E1.2_ElectromobilityElectromobility.pdf
BSS_1_E1.2_ElectromobilityElectromobility.pdfBSS_1_E1.2_ElectromobilityElectromobility.pdf
BSS_1_E1.2_ElectromobilityElectromobility.pdf
jungdan064

Breadth First Search with example and solutions

  • 1. BFS
  • 2. Breadth-first search Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a search key), and explores all of the neighbor nodes at the present depth prior to moving on to the nodes at the next depth level. It is implemented using a queue(FIFO). BFS traverses the tree shallowest node first, it would always pick the shallower branch until it reaches the solution (or it runs out of nodes, and goes to the next branch).
  • 3. Algorithm 3 Declare a queue and insert the starting vertex. Initialize a visited array and mark the starting vertex as visited. Follow the below process till the queue becomes empty: Remove the first vertex of the queue. Mark that vertex as visited. Insert all the unvisited neighbors of the vertex into the queue.
  • 4. Consider the Following Example Example-1
  • 5. Breadth First Search- STEP1 Choose the Starting Vertex as A VISIT A Insert A into the Queue A QUEUE:
  • 6. Breadth First Search- STEP2 Visit all adjacent vertices of A which are not visited(Here: D,E,B) Insert newly visited vertices into the queue and delete A from the Queue D E B QUEUE: RESULT: A
  • 7. Breadth First Search- STEP3 Visit all adjacent vertices of D which are not visited (No Vertex) Delete D from the Queue E B QUEUE: RESULT: A D
  • 8. Breadth First Search- STEP4 Visit all adjacent vertices of E which are not visited(Here C, F) Insert newly visited vertices into the queue and delete E from the Queue B C F QUEUE: RESULT: A D E
  • 9. Breadth First Search- STEP5 Visit all adjacent vertices of B which are not visited(No Vertex) Delete B from the Queue C F QUEUE: RESULT: A D E B
  • 10. Breadth First Search- STEP6 Visit all adjacent vertices of C which are not visited(Here G) Insert newly visited vertices into the queue and delete C from the Queue F G QUEUE: RESULT: A D E B C
  • 11. Breadth First Search- STEP7 Visit all adjacent vertices of F which are not visited(Here No Vertex) Delete F from the Queue G QUEUE: RESULT: A D E B C F
  • 12. Breadth First Search- STEP8 Visit all adjacent vertices of G which are not visited(Here No Vertex) Delete G from the Queue QUEUE: Queue Empty, End the Process RESULT: A D E B C F G
  • 13. BFS Traversal - Result AD EBCF G
  • 14. 14 Advantages BFS will provide a solution if any solution exists. If there are more than one solution for a given problem, then BFS will provide minimum solution which requires the least number of steps. Disadvantage It requires lot of memory since each level of the tree must be saved into memory to expand the next level. BFS needs lot of time if the solution is far a way from the root.
  • 15. Example 15 BFS Output will be ? Output of BFS : 1 2 3 4 5 6 7 8 9 10 11 12
  • 16. 16
  • 17. 17
  • 19. 19 Time complexity: Equivalent to the number of nodes traversed in BFS until the shallowest solution. T(n) = 1 + n^2 + n^3 + ... + n^s = O(n^s) s = the depth of the shallowest solution. n^i = number of nodes in level i. Space complexity: Equivalent to how large can the fringe get. S(n) = O(n^s)
  • 20. 20 Completeness: BFS is complete, meaning for a given search tree, BFS will come up with a solution if it exists. Optimality: BFS is optimal as long as the costs of all edges are equal.
  • 21. 21
  • 22. 22
  • 23. 23