1 / 26

Searching Algorithms

Searching Algorithms. Breadth First Search and Depth First Search. Why Search?. Greatest problem in Computer Science Has lead to a lot of new ideas and data structures Search engines before G oogle dawned were very slow. Search engines even took 10 minutes to search.

eunice
Download Presentation

Searching Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Searching Algorithms Breadth First Search and Depth First Search

  2. Why Search? • 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.

  3. 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.

  4. Breadth First Search • b- branching • d - depth 1 4 2 3 10 9 5 6 5 6 7 7 8

  5. Breadth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  6. Breadth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  7. Breadth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  8. Breadth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  9. Breadth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  10. Properties of BFS • 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

  11. Assignment:

  12. Depth First Search

  13. Depth First Search • b – branching • d - depth 1 4 2 3 10 9 5 6 5 6 7 7 8

  14. Depth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  15. Depth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  16. Depth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  17. Depth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  18. Depth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  19. Depth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  20. Depth First Search 1 4 2 3 10 9 5 6 5 6 7 7 8

  21. Can you guess the Time and Space complexity of the DFS?

  22. Can you guess the Time and Space complexity of the DFS? • Yes, Time complexity of DFS is O(bd)

  23. Properties of DFS • 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

  24. Answer for Breadth First Assignment

  25. Are you sure you know BFS and DFS? • 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?

  26. THANK YOU!!- Mino De Raj

More Related