An Image/Link below is provided (as is) to download presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.Content is provided to you AS IS for your information and personal use only.Download presentation by click this link.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.During download, if you can't get a presentation, the file might be deleted by the publisher.
演算法方式總覽 • The Divide-and-Conquer Strategy (個各擊破) • binary Searching、Quick Sort…. • The Greedy Method(貪婪演算法) • Prim MST、Kruskal MST、Djikstra's algorithm • Dynamic Programming(動態演算法) • 二項是係數、矩陣連乘、最佳二元搜尋樹… • Trace Back(回溯) • 圖形著色、漢米爾迴路問題…. • Tree Searching Strategy(樹的追蹤)
費氏數列(Fibonacci sequence) • Fibonacci sequence: 0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , … Fi = i if i 1 Fi = Fi-1 + Fi-2 if i 2 • Solved by a recursive program: • Much replicated computation is done. • It should be solved by a simple loop.
Dynamic Programming Dynamic Programming is an algorithm design method that can be used when the solution to a problem may be viewed as the result of a sequence of decisions 動態規劃是一種演算法的設計於當ㄧ個問題的解決方式是可以視為根據ㄧ連續的結果而得到。
最短路徑(The shortest path) • To find a shortest path in a multi-stage graph • Apply the greedy method : the shortest path from S to T : 1 + 2 + 5 = 8
The shortest path in multistage graphs • e.g. • The greedy method can not be applied to this case: (S, A, D, T) 1+4+18 = 23. • The real shortest path is: (S, C, F, T) 5+2+2 = 9.
資源分配問題 • The resource allocation problem • m resources, n projects profit Pi, j : j resources are allocated to project i. maximize the total profit.
The multistage graph solution • The resource allocation problem can be described as a multistage graph. • (i, j) : i resources allocated to projects 1, 2, …, j e.g. node H=(3, 2) : 3 resources allocated to projects 1, 2.
Find the longest path from S to T : (S, C, H, L, T), 8+5+0+0=13 2 resources allocated to project 1. 1 resource allocated to project 2. 0 resource allocated to projects 3, 4.