Dynamic Programming III Michael Tsai 201141 3 optimal Slides: 34 Download presentation Dynamic Programming III Michael Tsai 2011/4/1 3 例子: 有沒有optimal substructure 4 例子: 有沒有optimal substructure q r s t 5 例子: 有沒有optimal substructure 10 Dynamic Programming出招 1. 找出Optimal Substructure 11 12 13 Optimal Substructure 大問題的解裡面有小問題的解! 14 Overlapping subproblem 不同問題需要同樣子問題的解! 18 Dynamic Programming出招 4. 印出LCS結果 19 例題 B D C A B A 0 1 2 3 4 5 6 0 0 0 0 A 1 0 0 1 1 1 B 2 0 1 1 2 2 C 3 0 1 1 2 2 B 4 0 1 1 2 2 3 3 D 5 0 1 2 2 2 3 3 A 6 0 1 2 2 3 3 4 B 7 0 1 2 2 3 4 4 20 翻譯機問題 the machicolation 21 翻譯機問題 Optimal Binary Search Tree …… 22 23 i 0 0. 05 1 2 3 4 5 0. 10 0. 05 0. 10 0. 20 0. 10 0. 05 0. 10 25 Dynamic Programming出招 1. 找出Optimal Substructure 28 Dynamic Programming出招 2. 列出遞迴式子 (表示花費) 30 Dynamic Programming出招 3. 計算花費 i w w 11 22 33 44 55 66 j 00 11 22 33 44 55 31 e的填表順序 i ee j 00 11 22 33 44 55 11 22 橘色是會用到的subproblem 33 44 55 66 一次填一條對角線 34 Dynamic Programming出招 4. 印出Optimal Binary Search Tree結果 作業! 15. 5 -1 on p. 403