- 4
- 0
- 约1.63万字
- 约 35页
- 2018-01-25 发布于浙江
- 举报
a02-chap2-framework 算法导论 教学课件
* * * * * * * * * How to set up the recurrence for T(n), the worst-case running time of merge sort on n numbers? If one element n=1, takes constant time. When n1, Divide: The step just computes the middle of the subarray, one step. Thus, D(n)=Θ(1). Conquer: Recursively solve two subprolems, each of size n/2, which contributes 2T(n/2) to the running time. Combine: MERGE procedure shows C(n)=Θ(n) . 2.3.2 Analyzing divide-and-conquer algorithms MERGE-SORT(A, p, r) 1 if p r 2 Then q ← 3 MERGE-SORT(A, p, q) 4 MERGE-SORT(A, q+1, r) 5 MERGE(A, p, q, r) * 2.3.2 Analyzing divide-and-conquer algorithms Rewrite the recurrence equation solve the recurrence equation. * 2.3.2 Analyzing divide-and-conquer algorithms Add up the costs of all the levels. There are lgn+1 levels, each costing cn, for a total cost obviously, it outperforms insertion sort, whose running time is Θ(n2) , in the worst case, for large enough inputs. * Exercises and problems Exercises 分析Fibonacci序列 F(n) = F(n-1) + F(n-2) 如下算法的时间复杂度。 re_type f(type n) { if(n=2) return 1; else return f(n-1)+f(n-2); } f1 = 1; f2 = 1; for(i=3; i=n; i++){ f = f1 + f2; f1 = f2; f2 = f; } * Exercises and problems Exercises 2.3-1, 2.3-3, 2.3-5(编程), 2.3-6, 2.3-7(分析并编程实现) 补充:自己编程实现几种常用的排序算法(插入、冒泡、归并、快排、等等),并比较分析其运算时间。输入为随机产生的n个数,让n尽可能地大。 Problems 2-1, 2-3 (a, b) * * * * * * * * * * * * * * * * * * * * * * * * * * * * BeihangSoft.cn * * 2 Getting Started Goals: Start using framework for describing and analyzing algorithms (描述和分析算法的框架) Examine two algorithms for sorting: insertion sort and merge sort See how to describe algorithms in pseudocode, C/C++ and argue the correctness of that (如何描述算法) Begin using asymptotic notation to express running-time analysis (使用一致性符号来分析算法的运算时间) Learn the technique of “divide and conquer” in the context of merge sort (通过merge sort来学习分而治之方法) * 2 Getting Started 2.1 Insertion so
您可能关注的文档
- 663.长命百岁的健康知识.ppt
- 6a 第六章 静定结构的位移 结构力学电子教案.ppt
- 6c 静定桁架的位移计算 结构力学电子教案.ppt
- 6education Schools in Hollywood’s Pictures 英美文化概论 教学课件.ppt
- 6b 静定结构在荷载作用下的位移 结构力学电子教案.ppt
- 6Game开发包 手机游戏开发入门 教学课件.ppt
- 6Fortran的数据结构 FORTRAN语言程序设计 教学课件.ppt
- 6JAVA 输入输出流 java项目课件.ppt
- 6lecture 2_ solutions 语法资料课件.pdf
- 6EnPn 临床营养学 教学课件.ppt
- 2026年关于招聘“苍山卫士”林草资源管护中队队员6人的备考题库有答案详解.docx
- 2026年兴国县第三中学招聘教师备考题库及参考答案详解.docx
- 2026年佛山市公安局南海分局招聘狮山镇基层警务辅助人员30人备考题库及一套参考答案详解.docx
- 2026年关于中海油深圳电力有限公司空缺岗位公开招聘的备考题库参考答案详解.docx
- 2026年佛山市南海区里水和顺中心幼儿园招聘保育员备考题库完整答案详解.docx
- 客户资料处理保护承诺函7篇.docx
- “4.2 理解相关方的需求和期望” 过程基于 SIPOC 十五步分析、确定过程的理解与应用说明表【雷泽佳编制-2026A1】.docx
- “4.3确定质量管理体系的范围”过程基于SIPOC十五步分析、确定过程的理解与应用说明表【雷泽佳编制-2026A1】.docx
- “4.1 理解组织及其环境”过程基于 SIPOC 十五步分析、确定过程的理解与应用说明表【雷泽佳编制-2026A1】.docx
- “4.4 质量管理体系”过程基于 SIPOC 十五步分析、确定过程的理解与应用说明表【雷泽佳编制-2026A1】.docx
最近下载
- 雕塑维护方案养护.docx VIP
- 四川省成都市树德实验中学2024-2025学年七年级上学期期末考试道德与法治试题.docx VIP
- 对照不同光质补光对转色期葡萄品质和成分影响的初步探究.docx VIP
- 金属切削原理与刀具 配套课件.ppt
- T∕JNBDA 0009-2025 生殖医学高质量数据集建设规范.pdf VIP
- 上海高考:地理高频考点汇总.doc VIP
- 卫生部手术分级目录(2025年1月份修订).doc VIP
- DB11T 1087-2025公共建筑装饰装修工程质量验收标准.docx VIP
- 小学快乐体育教学活动的研究与实践课题研究报告.docx VIP
- 02S515 排水检查井图集建筑工程图集.docx VIP
原创力文档

文档评论(0)