1
CALTECH CS137 Winter2006 -- DeHon
1
CS137: Electronic Design Automation
Day 10: February 1, 2006 Dynamic Programming
CALTECH CS137 Winter2006 -- DeHon
2
Dynamic Programming Solution
- Solution described is general instance of
dynamic programming
- Require:
– optimal solution to subproblems is optimal solution to whole problem – (all optimal solutions equally good) – divide-and-conquer gets same (finite/small) number of subproblems
- Same technique used for instruction selection
CS137b: Day2
CALTECH CS137 Winter2006 -- DeHon
3
Dynamic Programming
- Two Examples
– SPLASH sequence matching/edit distances
- O(N2) operation in O(N) time with O(N)
hardware
– CMU parenthesis matching
- O(N3) operation in O(N) time with O(N2)
hardware
CALTECH CS137 Winter2006 -- DeHon
4
Sequence Matching
- Find edit distance between two strings
– E.g.
- Insert cost 1
- Delete cost 1
- Replace cost 2
- Match 0
- Primary Application:
– DNA Sequence comparison – Often compare new sequence against database
CALTECH CS137 Winter2006 -- DeHon
5
Edit Example
- SHMOO
– Add E (cost 1)
- SHMOOE
– Remove M (cost 1 + 1=2)
- SHOOE
– Replace O with R (cost 2+2=4)
- SHORE
CALTECH CS137 Winter2006 -- DeHon
6
Dynamic Programming
- Build a table representing string prefixes
– Only m×n cases compute
- Fill in costs
- Cell (m,n) is