- 1、本文档共52页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
SEARCHING (搜索)
Chapter7. Searching (搜索) 7.1 Introduction The Problem Search may succeed if there exists one record with the same key. There may be more than one record with the same key. In this case, return the first one. Search may fail if there is no record with the given key. Time complexity of the search algorithm: we count how many times one key is compared with another during a search. Internal searching: all the records are kept in high-speed memory. External searching, most of the records are kept in disk files. Assumptions Parameters for Search Functions 7.2 Sequential Search Algorithm Analysis Testing How to count? Definition of the class Key The class Record Choice of test data The test program Sequential search 7.3 Binary Search 7.3.1 Ordered Lists Implementation of ordered lists Overload insertion Overloaded insertion Binary Search The forgetful Version Algorithm Verification Termination Adjust the parameters Nonrecursive version Comparison Trees Analysing binary search Search terminates at leaves, half are successful and half are unsuccessful; All leaves are on the two adjacent levels; Worst case: the number of comparisons is the height of the tree; Average case? Comparison count 2-trees Some notations Analysis of binary_search_1 The maximum number of key comparisons is t = ?lg 2n?, approximately lg n +1; The average number of comparisons is about lg n +1; Lower Bounds Observations on 2-trees 本章要点 Exercises The recursion continue when top bottom. So we prove that the size of the interval [bottom, top] strictly decreases. When bottom top, we have bottom = mid top 2. The recursive calls reduce the size of the intervals either to top – (mid+1) or mid – bottom Both of which are strictly less then top – bottom. So the recursion terminates. We can adjust the above function to our standard search function conventions: Error_code run_recursive_binary_1(const Ordered_list the_list, const Key target, int position) { return
您可能关注的文档
- POWERPOINT 演示文稿 - 东北大学秦皇岛分校.ppt
- POWERPOINT 演示文稿 - 南海义工联.ppt
- POWERPOINT 演示文稿 - 影评学会.ppt
- POWERPOINT 演示文稿 - 扬中市外国语学校.ppt
- POWERPOINT 演示文稿 - 汽车动力系的检测和维护.ppt
- POWERPOINT 演示文稿 - 苏州工业园区思达德机械自控有限公司.ppt
- POWERPOINT 演示文稿 - 诸暨市纺织服装产业公共服务平台.ppt
- POWERPOINT 演示文稿 - 连云港外国语学校.ppt
- POWERPOINT 演示文稿 - 数字电视中文网.ppt
- POWERPOINT 演示文稿 - 统计预备知识.ppt
最近下载
- 防盗门破拆应用技术课程介绍讲解.docx VIP
- 1.2.1学习使用显微镜课件-人教版生物七年级上册 (1).pptx VIP
- 海水 G-F-降B-降E-降A调正谱 虎门销烟 刘岩.pdf VIP
- 超快闪蒸焦耳加热合成方法和用于实施其的系统.pdf VIP
- 高频热电场皮肤治疗仪产品技术要求.docx VIP
- 英语国家概况Unit14_Post-WWII_American_Foreign_Policy.ppt VIP
- 《建设工程监理规范》GB-T50319-2024版-附.pptx VIP
- 入党积极分子培训心得体会.docx VIP
- 2024河南平顶山市叶县招才引智卫生系统事业单位人才引进拟引进人员笔试备考试题及答案解析.docx VIP
- 超快闪蒸焦耳加热合成方法和用于实施其的系统.pdf VIP
文档评论(0)