midterm 3 revision n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Midterm 3 Revision PowerPoint Presentation
Download Presentation
Midterm 3 Revision

Loading in 2 Seconds...

play fullscreen
1 / 66

Midterm 3 Revision - PowerPoint PPT Presentation

71 Views
Download Presentation
Midterm 3 Revision
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. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Lecture 27 Midterm 3 Revision Prof. Sin-Min Lee Department of Computer Science San Jose State University

  2. Quotation • "Computer science is no more about computers than astronomy is about telescopes." • E. W. Dijkstra

  3. Edsger Dijkstra made many more contributions to computer science than the algorithm that is named after him. He was Professor of Computer Sciences in the University of Texas

  4. Map of fly times between various cities (in hours) 6 b a 2 c h 3 i 4 1 e 4 5 d 2 g f

  5. A more complicated network 2 8 0 1 2 1 4 3 9 2 1 3 4 7

  6. DAM representation 2 8 0 1 2 1 4 3 9 2 1 0 1 2 3 4 0 8 - 9 4 - 0 1 - - - 2 0 3 - - - 2 0 7 - - 1 - 0 3 7 4 0 1 2 3 4

  7. Shortest path • The shortest path between any two vertices is the one with the smallest sum of the weighted edges • Example: what is the shortest path between vertex 0 and vertex 1?

  8. Shortest path problem 2 8 0 1 2 1 4 3 9 2 1 Although it might seem like the shortest path is the most direct route... 3 4 7

  9. Shortest path problem 2 8 0 1 2 1 4 3 9 2 1 3 4 7

  10. Shortest path problem 2 8 0 1 2 1 4 3 9 2 1 3 4 7

  11. Shortest path problem 2 8 0 1 2 1 4 3 9 2 1 The shortest path is really quite convoluted at times. 3 4 7

  12. Shortest path solution • Attributed to Edsger Dijkstra • Solves the problem and also determines the shortest path between a given vertex and ALL other vertices! • It uses a set S of selected vertices and an array W of weights such that W[v] is the weight of the shortest path (so far) from vertex 0 to vertex v that passes through all of the vertices in S.

  13. How it works • If a vertex v is in S the shortest path from v0 to v involves only vertices in S • If v is not in S then v is the only vertex along the path that is not in S (in other words the path ends with an edge from some vertex in S to v. • Clear as mud?

  14. Shortest path problem 2 8 0 1 2 1 4 3 9 2 1 3 4 7

  15. Dynamic Programming One technique that attempts to solve problems by dividing them into subproblems is called dynamic programming. It uses a “bottom-up” approach in that the subproblems are arranged and solved in a systematic fashion, which leads to a solution to the original problem. This bottom-up approach implementation is more efficient than a “top-down” counterpart mainly because duplicated computation of the same problems is eliminated. This technique is typically applied to solving optimization problems, although it is not limited to only optimization problems. Dynamic programming typically involves two steps: (1) develop a recursive strategy for solving the problem; and (2) develop a “bottom-up” implementation without recursion.