组合算法基础教学课件.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
1 Finding k-thMinimum Another searching problem is to find the k-th smallest element in a sequence S of n element. One obvious method is to sort the sequence into non decreasing order (by Merge-Sort Algorithm) and then locate the k-th element. By Theorem 3 this method would require O(nlogn) comparisons. By a careful application of the divide-and-conquer strategy, we can find the k-th smallest element in O(n) comparisons. The basic idea is to partition the given sequence into three subsequences S1, S2, S3 such that S1 contains all elements less than m, S2 all elements equal to m, and S3 all elements greater than m. By counting the number of elements in S1 and in S2 we can determine in which of S1, S2, or S3 the k-th smallest element lies. In such a way we can reduce the problem to a smaller subproblem. In order to obtain a linear-time algorithm we must be able to find a partition element in linear time such that the sizes of the subsequences S1 and S3 are each no more than a fixed fraction of the size of S. The crux is in how the partition element m is chosen. The sequence S is partitioned into subsequences of five elements each. Each of them is sorted and from which the median is selected, medians of all subsequences form a sequence M, which contains onlyn/5elements. We can find the median of M five times faster than that of a sequence of n elements. 2 Dynamic Programming The divide-and-conquer approach partitions the problem into independent sub-problems, solves the sub-problems recursively, and then combine their solutions to solve the original problem. In contrast, the dynamic programming approach is applicable when the sub-problems are not independent, i.e., when subproblems share subsubproblems. It usually consists of the following steps: ? characterize the structure of an optimal solution, ? recursively define the value of an optimal solution, ? compute the value of an optimal solution, ? construct an optimal solution from comput

文档评论(0)

a13355589 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档