This preview shows page 1. Sign up to view the full content.
Unformatted text preview: attan Is Not A Perfect Grid
A3 A1 B What about diagonals? • The score at point B is given by:
sB = 2 21 sA2 + weight of the edge (A2, B) 22
S3,3 = 22 Traversing the Grid
3 different strategies: max sA3 + weight of the edge (A3, B) 0 0 12 sA1 + weight of the edge (A1, B) 20 5 0 4 12 4 12 0 1 3 8 18 3 2 2 3 2 5 7
5 Done! 1 5 1 5
3 8 17 3 5 3 4 13 5 A2 3 2 1 1 3 2 5 1 7 8 8 10 2 0 0 3 5 3 3 5 2 16
S2,2 = 16 0 5 3 2 1 3 3 8 2 1 1 17
S1,3 = 17 3 2 2 4 7 3 i 5 1 5 1 0 8 10 0 source 5 1
5 3 Dynamic Programming
a) a) Column by column
b) Row by row
c) Along diagonals
c) b) • solves problems by reusing solutions to
overlapping subproblems
• Approaches:
• Bottom up, starting from the smaller problems.
• Top down, recursively, using result caching
(memoization) • Thus, dynamic programming is simply
memoization of results of a recurrence, so
that time is not spent recomputing solutions
to subproblems.
A memoized function "remembers" the results corresponding to
some set of speciﬁc i...
View Full
Document
 Spring '12
 AsaBenHur
 Algorithms

Click to edit the document details