Notre Dame University Bangladesh Artificial Intelligence Breadth First Search
Notre Dame University Bangladesh Artificial Intelligence Breadth First Search
Bangladesh
Artificial Intelligence
CSE4103
Breadth First Search
Submitted To :
Humayara Binte Rashid
Lecturer
Department of CSE
Submitted By :
Abrity Paul Chowdhury
ID : 0692130005101005
Batch : CSE17
0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
0.2 Key Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
0.3 Working Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . 2
0.4 Pseudocode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
0.5 Applications of BFS . . . . . . . . . . . . . . . . . . . . . . . . . 3
0.6 Real Life Implementation . . . . . . . . . . . . . . . . . . . . . . 3
0.7 Advantages of BFS . . . . . . . . . . . . . . . . . . . . . . . . . . 6
0.8 Limitations of BFS . . . . . . . . . . . . . . . . . . . . . . . . . . 6
0.9 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1
0.1 Introduction
Breadth First Search (BFS) is a graph traversal algorithm that visits nodes level
by level. It explores the closest vertices first, unlike Depth First Search (DFS).
BFS is used in algorithms like Dijkstra’s and Prim’s and can detect cycles and
find shortest paths in unweighted graphs.
0.4 Pseudocode
Input: s as the source node
BFS(G, s):
• Let Q be a queue.
• Q.enqueue(s)
• Mark s as visited
• While (Q is not empty):
– v = Q.dequeue()
– For all neighbors w of v in Graph G:
2
∗ If w is not visited:
· Q.enqueue(w)
· Mark w as visited
3
The corresponding code
4
Figure:Web crawling using BFS part 2
Result
5
Figure:Web crawling using BFS result part 2
• Useful for solving problems like shortest path, cycle detection, and con-
nectivity.
0.9 Conclusion
In conclusion, web crawling using BFS is an efficient method to systematically
traverse and extract data from the web. By categorizing URLs into internal and
external links and managing them using a queue, the crawler ensures comprehen-
sive coverage up to a specified depth. This approach is valuable for applications
like web scraping, data mining, and building search engines.