版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、会计学1算法设计算法设计(shj)与分析基础三与分析基础三ch第一页,共44页。2problem)nchecking if all elements are distinct (element uniqueness)Also: nTopological sorting helps solving some problems for dags.nPresorting is used in many geometric algorithms.第1页/共44页第二页,共44页。32 also sufficient to sort array of size n (by mergesort).第2页/
2、共44页第三页,共44页。4(nlog n) Good or bad?Why do we have our dictionaries, telephone directories, etc. sorted?第3页/共44页第四页,共44页。5nAnother algorithm? Hashing第4页/共44页第五页,共44页。a11x1 + a12x2 + + a1nxn = b1 a1,1x1+ a12x2 + + a1nxn = b1a21x1 + a22x2 + + a2nxn = b2 a22x2 + + a2nxn = b2an1x1 + an2x2 + + annxn = bna
3、nnxn = bn第5页/共44页第六页,共44页。coefficient in the i-th column of that row 0第6页/共44页第七页,共44页。 0 5 -1/2 2 0 0 -6/5 -36/5Backward substitution x3= (-36/5) / (-6/5) = 6x2= (2+(1/2)*6) / 5 = 1x1= (6 6 + 4*1)/2 = 2第7页/共44页第八页,共44页。for k j +1 to n dot t + Aj, k * xk xj (Aj, n+1 - t) / Aj, j Efficiency: (n3) + (
4、n2) = (n3)第8页/共44页第九页,共44页。10nndelete第9页/共44页第十页,共44页。11第10页/共44页第十一页,共44页。12KK第11页/共44页第十二页,共44页。13Bonus: inorder traversal produces sorted list第12页/共44页第十三页,共44页。14n2-3 treesn2-3-4 treesnB-trees第13页/共44页第十四页,共44页。15第14页/共44页第十五页,共44页。16第15页/共44页第十六页,共44页。17第16页/共44页第十七页,共44页。18第17页/共44页第十八页,共44页。1
5、9第18页/共44页第十九页,共44页。20第19页/共44页第二十页,共44页。21nfrequent rotationsncomplexitynA similar idea: red-black trees (height of subtrees is allowed to differ by up to a factor of 2) 第20页/共44页第二十一页,共44页。22Note: Every node in a classical binary search tree is a 2-nodek1 k2 kn-1 k1k1, k2 ) kn-1第21页/共44页第二十二页,共44页
6、。23第22页/共44页第二十三页,共44页。24第23页/共44页第二十四页,共44页。25nB-trees第24页/共44页第二十五页,共44页。26第25页/共44页第二十六页,共44页。27第26页/共44页第二十七页,共44页。28第27页/共44页第二十八页,共44页。29nParent of node j is at j/2nParental nodes are represented in the first n/2locations9153421 2 3 4 5 69 5 3 1 4 2第28页/共44页第二十九页,共44页。30node第29页/共44页第三十页,共44页。
7、31第30页/共44页第三十一页,共44页。32第31页/共44页第三十二页,共44页。33第32页/共44页第三十三页,共44页。34 9 2 8 6 5 75 6 7 2 | 8 9 9 6 8 2 5 77 6 5 2 | 8 9 2 6 5 | 7 8 96 2 5 | 7 8 95 2 | 6 7 8 95 2 | 6 7 8 9 2 | 5 6 7 8 9第33页/共44页第三十四页,共44页。35worst-caseC(n) = Both worst-case and average-case efficiency: (nlogn) In-place: yesStability:
8、 no (e.g., 1 1)# nodes at level i 第34页/共44页第三十五页,共44页。36nTwo ways to handle priority queue in which highest priority = smallest number第35页/共44页第三十六页,共44页。37第36页/共44页第三十七页,共44页。38i 1 to n do power 1 power power * x for j 1 to i dop p + ai * powerpower power * x return pp p + ai* powerreturn p第37页/共44
9、页第三十八页,共44页。39 Same sequence of computations are obtained by simply arranging the coefficient in a table and proceeding as follows:coefficients2-1 3 1-5x=3第38页/共44页第三十九页,共44页。40第39页/共44页第四十页,共44页。412binary rep. of 13: 1 1 0 1 SM SM S SM accumulator: 1 12*a=aa2*a = a3 (a3)2 = a6 (a6)2*a= a13 (computed left-to-right)Efficiency: b M(n) 2b where b = log2 n + 1第40页/共44页第四十一页,共44页。421 a8 a4 a2a : a2 i terms a8* a4*a : product (computed right-to-left)Efficiency: same as that of left-to-right binary exponentiation第41页/共
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年大学大四(临床医学)外科学(骨科)综合测试题及答案
- 2025年高职农林牧渔类(农林维护保养)试题及答案
- 2025年中职(护理)基础护理操作规范试题及答案
- 2025年大学口腔医学技术(学术研究实务)试题及答案
- 2025年大学智能家居应用技术(应用技术)试题及答案
- 2025年大学食品加工工艺(薯片制作技术)试题及答案
- 2025年中职精细化工技术(洗涤剂制作)试题及答案
- 2025年中职(会展服务与管理)会展策划方案设计基础试题及解析
- 2025年高职第二学年(康复治疗技术)作业治疗试题及答案
- 2025年中职生物学(遗传学)试题及答案
- 2026年上饶职业技术学院高职单招职业适应性测试备考试题带答案解析
- 四川省德阳市2024-2025学年高一上学期语文期末检测试卷(含答案)
- 老年血液透析患者的日常护理要点
- 签定面条协议书
- 2025年党章测试题及答案详解
- 2025年营口辅警协警招聘考试真题及答案详解参考
- FSSC22000 V6食品安全管理体系管理手册及程序文件
- 2025-2026学年外研版(三起)五年级英语上册(全册)知识点复习要点归纳
- 2025年二十届四中全会知识测试题库(含答案)
- (正式版)DB54∕T 0357-2024 《雅江雪牛犊牛饲养管理技术规程》
- 2025年林果基地建设项目可行性研究报告
评论
0/150
提交评论