1 / 11

计算机问题求解

计算机问题求解. 解 题的一些基本策略. 问题讨论 - 1. 什么是“ algorithmic method”, 它在问题求解中有什么意义?. 问题讨论 - 2. 你 是 否 熟 悉 什 么“ algorithmic method ”,能不能举个例子说明某种方法?. 问题讨论 - 3. Greedy method: 它的力量和弱点是什么? 例子:简单而有效:最小生成树 例子:难以判断对与错:硬币问题 例 子:对很难的问题也能有作用. Kruskal’s Algorithm for MST. 2. B. Also Greedy strategy:

meris
Download Presentation

计算机问题求解

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.

E N D

Presentation Transcript


  1. 计算机问题求解 解题的一些基本策略

  2. 问题讨论 -1 • 什么是“algorithmic method”, 它在问题求解中有什么意义?

  3. 问题讨论 -2 • 你是否熟悉什么“algorithmic method”,能不能举个例子说明某种方法?

  4. 问题讨论 -3 • Greedy method: 它的力量和弱点是什么? • 例子:简单而有效:最小生成树 • 例子:难以判断对与错:硬币问题 • 例子:对很难的问题也能有作用

  5. Kruskal’s Algorithm for MST 2 B Also Greedy strategy: From the set of edges not yet included in the partially built MST, select the edge with the minimal weight, that is, local optimal, in another sense. A 6 3 4 7 G 3 1 5 F I H C 2 4 8 2 2 6 E D 1 edges included in the MST

  6. Greedy Fails Sometimes • If the available coins are of 1,5,12 units, and we have to pay 15 units totally, then the smallest set of coins is {5,5,5}, but not {12,1,1,1} • However, the correctness of greedy strategy on the case of {1,5,10,25} is not straightly seen.

  7. Next Fit Algorithm - NF • The strategy: Put a new item in the last bin if possible, or use a new bin. Never look back! • An example: S={0.2, 0.5, 0.4, 0.7, 0.1, 0.3, 0.8} 0.1 0.5 0.8 0.7 0.4 0.3 0.2

  8. Simple, but Not So Bad • For a given S, if the optimal value is m, NF algorithm uses at most 2m bins. • Proof: • Note that no two consecutive bins can contain object with total value less than 1, which mean half space is wasted at most.

  9. 问题讨论 -4 • divide-and-conquer: 为什么很有效?

  10. Quicksort: the Strategy • Dividing the array to be sorted into two parts: “small” and “large”, which will be sorted recursively. [first] [last] for any element in this segment, the key is not less than pivot. for any element in this segment, the key is less than pivot.

  11. 问题讨论 -5 • 集合运算的定理:为什么样子与逻辑运算很象?

More Related