- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 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
您可能关注的文档
最近下载
- 牦牛肉食用方法.pdf VIP
- 2025年危化品停车场安全预评价报告样本 .pdf VIP
- 2024-2025学年小学科学二年级上册(2024)青岛版(六三制2024)教学设计合集.docx
- 四年级英语单词大比拼训练.doc VIP
- 石油公司业务系统集成项目用户需求说明书V.doc VIP
- 社区卫生服务中心处方评价表.docx VIP
- 专题16 阅读理解之主旨大意题(题型与策略)(解析版)-2025年暑假新七年级英语衔接学习与能力提升专练(通用版).docx
- 财务三大报表(带公式).xls VIP
- 山西省名校2024-2025学年高一上学期10月联考试题含答案(9科试卷).pdf
- 儿童贫血相关疾病诊治进展题库答案-2025年华医网继续教育.docx VIP
文档评论(0)