- 11
- 0
- 约1.18万字
- 约 32页
- 2017-06-06 发布于河南
- 举报
算法Lecture 3
Algorithms Design and Analysis
Lecture 3
Beihang University
2008
Divide and Conquer (Continue)
Example 4. Finding Minimum (最小) and
Maximum (最大)
1
Backgound (背景)
Find the lightest (最轻) and heaviest (最重) of n elements
using a balance (天平) that allows you to compare the weight of 2
elements.
Minimize (使最小) the number of comparisons.
2
Max element
Find element with max weight (重量) from w[0, n-1]
maxElement=0
for (int i = 1; i n; i++)
if (w[maxElement] w[i]) maxElement = i;
Number of comparisons ( 比较次数) is n−1.
3
Obvious method
• Find the max of n elements making n−1 comparisons.
• Find the min of the remaining n−1 elements making n−2
comparisons.
• Total number of comparisons is 2n−3.
4
Divide and Conquer
How to combine?
• Find the min and max of {3,5,6,2,4,9,3,1}.
• Large instance.
• A = {3,5,6,2} and B = {4,9,3,1}.
• min(A) = 2, min(B) = 1.
• max(A) = 6, max(B) = 9.
• min{min(A),min(B)} = 1.
• max{max(A), max(B)} = 9.
5
Dividing Into Smaller Problems
{8,2,6,3,9,1,7,5,4,2,8}
{8,2,6,3,9} {1,7,5,4,2,8}
{8,2} {6,3,9} {1,7,5} {4,2,8}
{6} {3,9} {1} {7,5} {4} {2,8}
6
Solve Small Problems and Combine
{1,9}
{2,9}
您可能关注的文档
- 基于粒子系统的快速而有效的布模拟算法.pdf
- 2015论榆神府矿区煤炭资源的适度开发问题.pdf
- 北京外国语大学考博英语词汇文档.pdf
- 产煤发达国家生产现状及安全形势分析.pdf
- 机器学习中的贝叶斯进阶.pdf
- 分组测试与迫进控制标准.pdf
- 背包问题在硬币抛掷协议上的研究.pdf
- 2012年1月高三学生必须背记的单词(文字打印版).pdf
- 在职研究生基础班词汇小班课.pdf
- 教案5穷举法.pdf
- 广东省广州省实验中学教育集团2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州大学附属中学2025-2026学年八年级上学期奥班期中物理试题(解析版).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(含答案).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第八十六中学2025-2026学年八年级上学期期中物理试题(解析版).docx
- 广东省广州市第八十九中学2025-2026学年八年级上学期期中考试物理试题(含答案).docx
- 广东省广州市第二中学2025-2026学年八年级上学期期中考试物理试题(解析版).docx
- 2026《中国人寿上海分公司营销员培训体系优化研究》18000字.docx
- 《生物探究性实验教学》中小学教师资格模拟试题.docx
最近下载
- 雷克萨斯-Lexus NX-产品使用说明书-NX200-ZGZ10L-AWXLPC2-NX200NX200t_OM78064C_01-1412-001.pdf VIP
- 小学语文五年级第二学期第二单元整体作业设计.docx
- 外研版小学英语(三年级起点)三年级上册Module2-Unit1同步检测.doc VIP
- 2025年河南省平顶山市中考生物试卷(含答案).pdf
- 【TD产业联盟】全球5G_6G产业发展报告(2024-2025).pdf VIP
- 乡镇卫生院年休假制度.docx VIP
- 职业技术教育教学管理新制度学分制.doc VIP
- 健康生活小常识100条.docx VIP
- 职业学校学分制实施细则.docx
- AP微观经济学 2010年真题 附答案和评分标准 AP Microeconomics 2010 Real Exam with Answers and Scoring Guidelines.pdf VIP
原创力文档

文档评论(0)