- 1、本文档共40页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Sorting And Searching
B.Ramamurthy Sorting And Searching CSE116A,B Introduction The problem of sorting a collection of keys to produce an ordered collection is one of the richest in computer science. The richness derives from the fact that there are a number of ways of solving the sorting problem. Sorting is a fascinating operation that provides a model for investigating many problems in Computer Science. Ex: analysis and comparison of algorithms, divide and conquer, space and time tradeoff, recursion etc. Sorting Comparison based: selection, insertion sort (with online animations) Divide and conquer: merge sort, quick sort (with animations from supplements of your text book) Priority Queue /Heap based: heap sort Assume: Ascending order for all our discussion Selection Sort Select the first smallest element, place it in first location (by exchanging contents of locations), find the next smallest, place it in the next location, and so on. We will look at an example, an algorithm, analyze the algorithm, and look at code implementation. Selection Sort: Example Selection Sort Pseudo Code Let cursor be pointer to first element of an n element list to be sorted. Repeat until cursor points to last but one element. 2.1 Search for the smallest element in the list starting from the cursor. Let it be at location target. 2.2 Exchange elements at cursor and target. 2.3 Update cursor to point to next element. Sort Analysis Let el be the list; n be the number of elements; cursor = 0; target = 0; while (cursor n-1) 2.1.1 target = cursor; 2.1.2 for (i= cursor+1; i n; i++) if (el[i] el[target]) target =i; 2.2 exchange (el[target], el[cursor]); // takes 3 assignments 2.3 cursor++; (n-1) *4 + 2 *(n + (n-1) + (n-2) ..1) 4n – 4 + 2*n(n+1)/2 = 4n – 4 + n2 + n = n2 + 5n - 4 An2 + B n + C where A= 1, B = 5, C = -4; for large n, drop the constant, lower order term in n, and the multiplicative constant to get big-O notation O(n2) – quadratic sort
您可能关注的文档
- 高一英语必修2 unit3.ppt
- 连衣裙高跟鞋如何搭配 夏日穿衣必杀技盘点.doc
- QCC活.ppt
- ch9:PLANNING AND ESTIMATING.ppt
- 2.IE 7-Tools and 7-Wastes.pptx
- 短学期.pptx
- 9微生物生态.ppt
- 2011归档规程.doc
- 改善工程的想法.ppt
- hysys2006.5and v7.0 new.ppt
- 2025年中国三正庚基氧膦数据监测报告.docx
- 2025年中国五金机壳数据监测研究报告.docx
- 2025年中国防滑凳数据监测报告.docx
- 2025年中国差别化连续聚酯装置数据监测报告.docx
- 2025年综合类-移动通信机务员鉴定-中国联通考试历年真题摘选带答案(5卷100道合辑-单选题).docx
- 2025年综合类-计划生育主治医师-性传播疾病历年真题摘选带答案(5卷单选题百道集合).docx
- 2025年中国DC连接线数据监测研究报告.docx
- 2025年中国重金属铅速测盒数据监测研究报告.docx
- 2025年中国八挂碟数据监测研究报告.docx
- 2025年中国K型热电偶数据监测研究报告.docx
最近下载
- 摩托罗拉XiR_M3688_ServerManual维修手册.pdf VIP
- 奥西替尼杂质研究总结.pdf VIP
- 2024《格兰仕电器公司成本管理问题调查研究》8600字.docx VIP
- 中小学英语教师语音语调训练.ppt
- 《严格规范涉企行政检查》知识培训.pptx VIP
- MODS(多器官功能障碍综合征).ppt VIP
- 高中政治统编版必修一:(综合探究二)方向决定道路 道路决定命运.pptx
- VW75210-2 2011 (LV216-2) CN-电动汽车的高压屏蔽电缆要求和试验.pdf VIP
- 2022版小学《体育与健康课程标准》考试复习题库资料(含答案).pdf VIP
- 人工智能在邮政业的应用前景.pptx VIP
文档评论(0)