电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

算法分析技术概要概要课件

36页
  • 卖家[上传人]:F****n
  • 文档编号:88224675
  • 上传时间:2019-04-21
  • 文档格式:PPT
  • 文档大小:3.16MB
  • / 36 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • 1、算法分析技术概要,2007/06/1,2,算法分析技术,求和技术 Solving summations 递归(分治)算法 Solving recurrence 估计与归纳证明法 The substitution method 递归树展开法 The recursion-tree method The master method 快速排序算法及复杂度分析 其他排序算法,3,求和技术 Solving summations : Shifting method binary insertion sort,for i = 1 to n biInsert( Ai, S);,S:,Sn=ki=1 i*2i-1 =1*20+2*21+3*22+4*23 +(i-1)*2i-2+i*2i-1+(i+1)*2i+k*2k-1,2*Sn=k i=1 i*2i-1*2=k i=1 i*2i = 1*21+2*22+3*23+ +(i-2)*2i-2 +(i-1)*2i-1+i*2i+1+(k-1)*2k-1+k*2k,Sn = k*2k - k i=2 2i-1 + 1 = k*2k - 2k + 1 = n*

      2、log(n) n + 1,4,Solving summations : Binary insertion sort,由于二分查找最后要定位点在的一个具体的点上,而且这个点必须是刚好必要插入的小的,所以必然是要使左指针与右指针相互移过,故每插入一个,需要比较的次数为log2n。一共需要比较log2n, log2n1时,实际上,在n10时已经是很好的近似了) 所以 nlog2n-n = log2n= nlog2n, 故二分法在比较的时间复杂度: T(n) = O(nlog2n),张浩炜提供,5,Solving recurrence (chapter 4) The substitution method (4.1),Merge sort:,(the base cases),6,The substitution method (cont.),Guess: T (n) = O(n lg n). Prove: T (n) c nlg n (for a constant c 0.),T(n) 2(c n/2lg(n/2) + n cn lg(n/2) + n = cn lg n - cn lg 2

      3、+ n = cn lg n - cn + n cn lg n,7,The recursion-tree method (4.2),The recursion tree for T (n) = 3T (n/4) + cn2, Drawing out a recursion tree is a straightforward way to devise a good guess.,Cost of dividing problem & combination,8,The recursion tree for T (n) = 3T (n/4) + cn2,3log4n,Base cases,9,The master method (4.3),f(n) nlogba T(n) = (nlogba) f(n) =(nlogba) T(n) = (nlogba lgn) f(n) nlogba T(n) = (f(n),T(n) =,10,11,Application of Master-theorem,12,Application of Master-theorem (cont.),13,Appl

      4、ication of Master-theorem (cont.),14,Application of Master-theorem (cont.),15,Compute Fibonacci numbers,16,Compute Fibonacci numbers,17,关于上次课的作业,冒泡法排序可以考虑通过一个increase变量替代重复的循环结构。最好能有“没有交换就停止”的策略。 重排数组作业,设置头尾指针,交换正负,直到头=尾 算法分析:注意区别最坏情况和平均情况的计算方法。 参考教材 p248的等概率情况下的算法代价分析。,18,Quicksort (chapter 7),19,Quicksort (cont.),Divide: Partition (rearrange) the array Ap r into two subarrays Ap q - 1 and Aq + 1 r such that: each element of Ap q - 1 Aq Conquer: Sort the two subarrays Ap q -1 and Aq +1 r by rec

      5、ursive calls to quicksort. Combine: Since the subarrays are sorted in place, no work is needed to combine them: the entire array Ap r is now sorted.,20,Quicksort (cont.),O(n),?,21,Quicksort (cont.),22,Quicksort (cont.),23,Quicksort (cont.),24,Quicksort (cont.),25,Quicksort (cont.),26,Lower bounds for sorting (8.1),27,The decision-tree model,4=6,28,The decision-tree model(cont.),29,30,31,Counting sort (8.2),32,COUNTING-SORT(A, B, k),1 (for i 0 to k) do Ci 0 /initialize Ci 2 (for j 1 to lengthA )

      6、do CAj CAj + 1 /Ci now contains the number of elements equal to i. 3 (for i 1 to k) do Ci Ci + Ci - 1 /Ci now contains the number of elements less than or equal to i. 4 (for j lengthA downto 1) do BCAj Aj ; /CAj store the rank of Aj CAj CAj - 1 ; ,33,Example of counting sort,34,35,36,Home work (不用提交,可以相互讨论),Exercises 4.3-1 Use the master method to give tight asymptotic bounds for the following recurrences. T (n) = 4T(n/2) + n. T (n) = 4T(n/2) + n2. T (n) = 4T(n/2) + n3 Exercises 4.3-2 The recurrence T(n) = 7T (n/2)+n2 describes the running time of an algorithm A. A competing algorithm A has a running time of T(n) = aT(n/4) + n2. What is the largest integer value for a such that A is asymptotically faster than A? 28号下午考试。,

      《算法分析技术概要概要课件》由会员F****n分享,可在线阅读,更多相关《算法分析技术概要概要课件》请在金锄头文库上搜索。

      点击阅读更多内容
    最新标签
    发车时刻表 长途客运 入党志愿书填写模板精品 庆祝建党101周年多体裁诗歌朗诵素材汇编10篇唯一微庆祝 智能家居系统本科论文 心得感悟 雁楠中学 20230513224122 2022 公安主题党日 部编版四年级第三单元综合性学习课件 机关事务中心2022年全面依法治区工作总结及来年工作安排 入党积极分子自我推荐 世界水日ppt 关于构建更高水平的全民健身公共服务体系的意见 空气单元分析 哈里德课件 2022年乡村振兴驻村工作计划 空气教材分析 五年级下册科学教材分析 退役军人事务局季度工作总结 集装箱房合同 2021年财务报表 2022年继续教育公需课 2022年公需课 2022年日历每月一张 名词性从句在写作中的应用 局域网技术与局域网组建 施工网格 薪资体系 运维实施方案 硫酸安全技术 柔韧训练 既有居住建筑节能改造技术规程 建筑工地疫情防控 大型工程技术风险 磷酸二氢钾 2022年小学三年级语文下册教学总结例文 少儿美术-小花 2022年环保倡议书模板六篇 2022年监理辞职报告精选 2022年畅想未来记叙文精品 企业信息化建设与管理课程实验指导书范本 草房子读后感-第1篇 小数乘整数教学PPT课件人教版五年级数学上册 2022年教师个人工作计划范本-工作计划 国学小名士经典诵读电视大赛观后感诵读经典传承美德 医疗质量管理制度 2 2022年小学体育教师学期工作总结 2022年家长会心得体会集合15篇
    关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
    手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
    ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.