31251 Lecture Notes - Lecture 6: Dynamic Programming

64 views1 pages
Dynamic Programming
Dynamic programming looks a lot like Divide-and-Conquer, but subinstances overlap.
Usually implemented with some sort of table that keeps track of subinstance
solutions.
Normally they work bottom-up (the reverse of D&C):
Solve the smallest subinstances, combine them to make bigger subinstances, keep
going until you have the whole thing.
Can be done top-down (recursively) as well.
What makes it work?
Optimal Substructure: The same as greedy algorithms and D&C.
Overlapping Subproblems: As mentioned before.
Single Source Shortest Path
In unweighted graphs, the distance between two vertices is easy to calculate:
oJust do a breadth first search.
oIf you’re looking for a particular vertex, stop when you find it.
oThe distance is the same as the number of iterations taken to get to the
vertex.
In weighted graphs, it’s not so easy.
oThe lowest weight path is not always the path with fewest edges.
1 | P a g e
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents