Chapter6算法概论概要1
6.5 Chain matrix multiplication The optimal substructure property: for a tree to be optimal, its subtree must also be optimal. Subproblem corresponding to a subtree: product of the form Ai? Ai+1?… ? Aj For 1?i ?j?n, the optimal value array C(i,j) = minimum cost of multiplying Ai? Ai+1?… ? Aj The splitting point k: split the product into two pieces, of the form Ai? … ? Ak and Ak+1?… ? Aj The total cost is the cost of these two partial products plus the cost of combining them * 6.5 Chain matrix multiplication A dynamic programming algorithm: The number of subproblem: O(n2), each takes O(n) to compute The overall running time: O(n3) * 6.6 Shortest path Shortest reliable paths Avoid paths with too many edges All-pairs shortest paths Find the shortest path not just between s and t but between all pairs of vertices The traveling salesman problem Each city is visited exactly once Minimize the overall distance traveled * 6.6 Shortest path Shortest reliable paths Problem: the shortest path from s to t that uses at most k edges Subproblem: dist(v,i) to the length of the shortest path from s to v that uses i edges, i?k The general update equation: * 6.6 Shortest path All-pairs shortest paths Find the shortest path between all pairs of vertices. If execute the Bellman-Ford algorithm (maybe negative edges) for |V| times, one for each starting node, the running time would be O(|V|2|E|). A better way: the O(|V|3) dynamic programming-based Floyd-Warshall algorithm * 6.6 Shortest path dynamic programming-based Floyd-Warshall algorithm Number the vertices in V as {1,2,…,n} dist(i, j, k): the length of the shortest path from i to j in which only nodes {1,2,…,k} can be used as intermediates dist(i, j, 0): the length of the direct edge between i and j, if it exists, and is ? otherwise Expand the intermediate set to include an extra node k A shorter path from i to j that uses k goes through k just once (assume that there are no negative cycles) Update dist
您可能关注的文档
- Chapter10概要1.ppt
- chapter 3跨文化课件概要1.ppt
- Chapter11 FIELD EQUATIONS AND BOUNDARY CONDITIONS IN FLUID MECHANICS.ppt东鹏已改cyt已改概要1.pptx
- chapter10 Investment, Net Exports, and Interest Rates(宏观经济学加州大学詹姆斯·布拉德福特·德隆)概要1.ppt
- chapter11(多元线性)概要1.ppt
- Chapter13 Overall Audit Planand Audit Program(审计学英文版)概要1.ppt
- Chapter15 Audit Sampling for Tests of Controls and (审计学英文版)概要1.ppt
- Chapter16 Usinging the computer用电脑概要1.ppt
- chapter15 International Economic Policy(宏观经济学加州大学詹姆斯·布拉德福特·德隆)概要1.ppt
- chapter2 各类化合物的制备方法概要1.ppt
- 2026冬奥会知识竞赛题库200道附参考答案【精练】.docx
- 2026冬奥会知识竞赛题库200道有完整答案.docx
- 2026冬奥会知识竞赛题库200道附参考答案【培优】.docx
- 2026冬奥会知识竞赛题库200道附参考答案(完整版).docx
- 2026冬奥会知识竞赛题库200道附参考答案【典型题】.docx
- 2026冬奥会知识竞赛题库200道带答案(最新).docx
- 2026冬奥会知识竞赛题库200道附参考答案(预热题).docx
- 2026冬奥会知识竞赛题库200道带答案(模拟题).docx
- 2026冬奥会知识竞赛题库200道附参考答案【研优卷】.docx
- 2026冬奥会知识竞赛题库200道带答案(轻巧夺冠).docx
原创力文档

文档评论(0)