Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot...
-
Upload
sheryl-butler -
Category
Documents
-
view
231 -
download
0
description
Transcript of Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot...
![Page 1: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/1.jpg)
Breadth First Search and Depth First Search
Searching Algorithms
![Page 2: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/2.jpg)
Greatest problem in Computer Science
Has lead to a lot of new ideas and data structures
Search engines before Google dawned were very slow. Search engines even took 10 minutes to search.
Why Search?
![Page 3: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/3.jpg)
Trees were created to store data
Finding the data requires searching
Graph searching and Tree Searching algorithms that we are going to learn today are BFS and DFS.
![Page 4: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/4.jpg)
Breadth First Searchb- branchingd - depth
1
75
4
6
3
765
2
89
10
![Page 5: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/5.jpg)
Breadth First Search 1
75
4
6
3
765
2
89
10
![Page 6: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/6.jpg)
Breadth First Search 1
75
4
6
3
765
2
89
10
![Page 7: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/7.jpg)
Breadth First Search 1
75
4
6
3
765
2
89
10
![Page 8: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/8.jpg)
Breadth First Search 1
75
4
6
3
765
2
89
10
![Page 9: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/9.jpg)
Breadth First Search 1
75
4
6
3
765
2
89
10
![Page 10: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/10.jpg)
Worst case performance – O(bd)Worst case space complexity - O(bd)Implemented using a queue. But you are free
to experiment with other data structures
Properties of BFS
![Page 11: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/11.jpg)
Assignment:
![Page 12: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/12.jpg)
Depth First Search
![Page 13: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/13.jpg)
Depth First Searchb – branchingd - depth
1
75
4
6
3
765
2
89
10
![Page 14: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/14.jpg)
Depth First Search 1
75
4
6
3
765
2
89
10
![Page 15: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/15.jpg)
Depth First Search 1
75
4
6
3
765
2
89
10
![Page 16: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/16.jpg)
Depth First Search 1
75
4
6
3
765
2
89
10
![Page 17: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/17.jpg)
Depth First Search 1
75
4
6
3
765
2
89
10
![Page 18: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/18.jpg)
Depth First Search 1
75
4
6
3
765
2
89
10
![Page 19: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/19.jpg)
Depth First Search 1
75
4
6
3
765
2
89
10
![Page 20: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/20.jpg)
Depth First Search 1
75
4
6
3
765
2
89
10
![Page 21: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/21.jpg)
Can you guess the Time and Space complexity of the DFS?
![Page 22: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/22.jpg)
Can you guess the Time and Space complexity of the DFS?
Yes, Time complexity of DFS is O(bd)
![Page 23: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/23.jpg)
Worst case performance – O(bd)Worst case space complexity - O(d)Implemented using a queue. But you are free
to experiment with other data structures
Properties of DFS
![Page 24: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/24.jpg)
Answer for Breadth First Assignment
![Page 25: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/25.jpg)
What will you do if there is a loop in DFS? What are the data structures to use?
In order to reduce space complexity in BFS, why don’t we just delete all the nodes that are visited until the previous depth?
Are you sure you know BFS and DFS?
![Page 26: Breadth First Search and Depth First Search. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before.](https://reader035.fdocuments.us/reader035/viewer/2022062219/5a4d1b017f8b9ab059986a66/html5/thumbnails/26.jpg)
THANK YOU!!- Mino De Raj