Outlines u n n Concepts of Greedy Approach

  • Slides: 21
Download presentation

國立聯合大學 資訊管理學系 ) 演算法課程 (陳士杰 ▓ Outlines u 本章重點 n n Concepts of Greedy

國立聯合大學 資訊管理學系 ) 演算法課程 (陳士杰 ▓ Outlines u 本章重點 n n Concepts of Greedy Approach Dynamic Programming v. s. Greedy Approach Minimum Spanning Trees The Greedy Approach versus Dynamic Programming: The Knapsack Problem 2

國立聯合大學 資訊管理學系 ) 演算法課程 (陳士杰 ▓ Concepts of Greedy Approach u Greedy approach grabs

國立聯合大學 資訊管理學系 ) 演算法課程 (陳士杰 ▓ Concepts of Greedy Approach u Greedy approach grabs data items in sequence, each time taking the one that is deemed "best" best according to some criterion, without regard for the choices it has made before or will in the future. u Like dynamic programming, greedy algorithms are often used to solve optimization problems. However, the greedy approach is more straightforward n In dynamic programming, programming a recursive property is used to divide an instance into smaller instances. In the greedy approach, there is no division into smaller instances. n A greedy algorithm arrives at a solution by making a sequence of choices, each of which simply looks the best at the moment. 3

國立聯合大學 資訊管理學系 ) 演算法課程 (陳士杰 u. A greedy algorithm starts with an empty set

國立聯合大學 資訊管理學系 ) 演算法課程 (陳士杰 u. A greedy algorithm starts with an empty set and adds items to the set in sequence until the set represents a solution to an instance of a problem. u Each n A selection procedure: procedure ¡ n Chooses the next item to add to the set. The selection is performed according to a greedy criterion that satisfies some locally optimal consideration at the time. A feasibility check: check ¡ n iteration consists of the following components: Determines if the new set is feasible by checking whether it is possible to complete this set in such a way as to give a solution to the instance. A solution check: check ¡ Determines whether the new set constitutes a solution to the instance. 8