1 / 28

CSCE 310: Data Structures Algorithms

Design and Analysis of Algorithms - Chapter 8. 2. Giving credit where credit is due:Most of the lecture notes are based on the slides from the Textbook's companion website http://www.aw-bc.com/info/levitinSome of the notes are based on slides created by Dr. Philippe Laborie, ILOG and Mark Llewe

eugenia
Télécharger la présentation

CSCE 310: Data Structures 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. Design and Analysis of Algorithms - Chapter 8 1 CSCE 310: Data Structures & Algorithms

    2. Design and Analysis of Algorithms - Chapter 8 2 Giving credit where credit is due: Most of the lecture notes are based on the slides from the Textbooks companion website http://www.aw-bc.com/info/levitin Some of the notes are based on slides created by Dr. Philippe Laborie, ILOG and Mark Llewellyn, University of Central Florida. I have modified many of their slides and added new slides. CSCE 310: Data Structures & Algorithms

    3. Design and Analysis of Algorithms - Chapter 8 3 Examples of dynamic programming algorithms

    4. Design and Analysis of Algorithms - Chapter 8 4 Warshalls algorithm: transitive closure

    5. Design and Analysis of Algorithms - Chapter 8 5 Warshalls algorithm

    6. Design and Analysis of Algorithms - Chapter 8 6 Warshalls algorithm

    7. Design and Analysis of Algorithms - Chapter 8 7 Warshalls algorithm

    8. Design and Analysis of Algorithms - Chapter 8 8 Warshalls algorithm

    9. Design and Analysis of Algorithms - Chapter 8 9 Warshalls algorithm

    10. Design and Analysis of Algorithms - Chapter 8 10 Warshalls algorithm

    11. Design and Analysis of Algorithms - Chapter 8 11 Warshalls algorithm

    12. Design and Analysis of Algorithms - Chapter 8 12 Warshalls algorithm

    13. Design and Analysis of Algorithms - Chapter 8 13 In-class exercises 8.2.1 Apply Warshalls algorithm to find the transitive closure of the digraph defined by the following adjacency matrix

    14. In-class exercises Problem 2 a. What is the time efficiency of Warshalls algorithm? Design and Analysis of Algorithms - Chapter 8 14

    15. In-class exercises Problem 2 a. What is the time efficiency of Warshalls algorithm? b. How to solve this finding all paths in a directed graph problem by a traversal-based algorithm (BFS-based or DFS-based)? Design and Analysis of Algorithms - Chapter 8 15

    16. In-class exercises Problem 2 a. What is the time efficiency of Warshalls algorithm? b. How to solve this finding all paths in a directed graph problem by a traversal-based algorithm (BFS-based or DFS-based)? c. Explain why the time efficiency of Warshalls algorithm is inferior to that of traversal-based algorithm for sparse graphs represented by their adjacency lists. Design and Analysis of Algorithms - Chapter 8 16

    17. Design and Analysis of Algorithms - Chapter 8 17 Floyds algorithm: all pairs shortest paths

    18. Design and Analysis of Algorithms - Chapter 8 18 Floyds algorithm: all pairs shortest paths

    19. Design and Analysis of Algorithms - Chapter 8 19 Floyds algorithm: all pairs shortest paths

    20. Design and Analysis of Algorithms - Chapter 8 20 Floyds algorithm: all pairs shortest paths

    21. Design and Analysis of Algorithms - Chapter 8 21 Floyds algorithm: all pairs shortest paths

    22. Design and Analysis of Algorithms - Chapter 8 22 Floyds algorithm: all pairs shortest paths

    23. Design and Analysis of Algorithms - Chapter 8 23 In-Class Exercises Apply the Floyds algorithm to the following problem instance: D(0) =

    24. Enhanced Floyds Algorithm

    25. Design and Analysis of Algorithms - Chapter 8 25 In-Class Exercises Apply the enhanced Floyds algorithm, which finds the shortest paths and their lengths, to the following problem instance: D(0) =

    26. Dynamic programming Dynamic programming is a technique for solving problems with overlapping subproblems. It suggests solving each smaller subproblem once and recording the results in a table from which a solution to the original problem can be then obtained. Design and Analysis of Algorithms - Chapter 8 26

    27. Dynamic programming Dynamic programming is a technique for solving problems with overlapping subproblems. It suggests solving each smaller subproblem once and recording the results in a table from which a solution to the original problem can be then obtained. What are the overlapping subproblems in Floyds algorithm? Design and Analysis of Algorithms - Chapter 8 27

    28. Principle of Optimality General principle that underlines dynamic programming algorithms for optimization problems: Principle of optimality: an optimal solution to any instance of an optimization problem is composed of optimal solutions to its subinstances. The principle of optimality holds in most cases. (A rare example: it fails for finding longest simple paths).

    29. 29 In-Class Exercises Index: 0 1 2 i-1 i i+1 n aj aj+1 aj+2 an a0 a1 ... aj-1 where a0 < a1 < a2 < a3 < < an How to find out the corresponding index i for a0? Given an array a0 a1 ... an-1, where a0 < a1 < a2 < a3 < < an-1 , design an efficient algorithm to tell if there are three items in the array such that ax + ay = az , what is the time efficiency of your algorithm?

More Related