- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
How to Pick the Pivot (2/2) Strategy 3: Median of three Ideally, the pivot should be the median of input S, which divides the input into two sequences of almost the same length However, computing median takes O(n) So we find the approximate median via Pivot = median of the left-most, right-most, and the center element of the array S Quick-Sort * Example of Median of Three Let input S = {6, 1, 4, 9, 0, 3, 5, 2, 7, 8} left=0 and S[left] = 6 right=9 and S[right] = 8 center = (left+right)/2 = 4 and S[center] = 0 Pivot = median of {6, 8, 0} = 6 Quick-Sort * Dealing with Small Arrays For small arrays (say, N ≤ 20), Insertion sort is faster than quicksort Quicksort is recursive So it can spend a lot of time sorting small arrays Hybrid algorithm: Switch to using insertion sort when problem size is small (say for N 20) Quick-Sort * Quick-Sort * Summary of Sorting Algorithms Algorithm Time Notes selection-sort O(n2) in-place, stable slow (good for small inputs) insertion-sort O(n2) in-place, stable slow (good for small inputs) quick-sort O(n log n)expected in-place, unstable, randomized fastest (good for large inputs) heap-sort O(n log n) in-place, unstable fast (good for large inputs) merge-sort O(n log n) not in-place, stable fast (good for huge inputs) Quick-Sort * * Quick-Sort ? 2004 Goodrich, Tamassia ? 2004 Goodrich, Tamassia Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort Quick-Sort * Quick-Sort 7 4 9 6 2 ? 2 4 6 7 9 4 2 ? 2 4 7 9 ? 7 9 2 ? 2 9 ? 9 Quick-Sort Inventor Invented by Hoare in 1962 Quick-Sort * 查爾斯·安東尼·理察·霍爾爵士(Charles Antony Richard Hoare,縮寫為 C. A. R. Hoare,1934年1月11日- ),生於斯里蘭卡可倫坡,英國計算機科學家,圖靈獎得主。他設計了可快速進行排序程序的快速排序(quick sort)演算法,提出可驗證程式正確性的霍爾邏輯(Hoare logic) 、以及提出可訂定並時程序(concurrent process)的交互作用(如哲學家用餐問題(dining philosophers problem)的交談循序程續(CSP, Communicating Sequential Processes)架構 。 (圖及說明摘自維基百科) About Quick-Sort Fastest known sorting algorithm in pract
您可能关注的文档
- PPT制作: 章丹妮QQ1017570417课件.ppt
- PPT制作:蔡冰冰采编:陈惠闲演讲:林妙常课件.ppt
- PPT制作部门2011年述职报告课件.ppt
- PPT制作要求课件.ppt
- PPT中的动画课件.ppt
- PQ 项目:优先基本用药课件.ppt
- PQDD 论文订购说明课件.ppt
- PQDD--(ProQuest Digital Dissertations)课件.ppt
- PQDD学位论文全文库课件.ppt
- PQDT论文提交系统课件.ppt
- rén xū课件.ppt
- R2C管理系统与前台流程说明课件.ppt
- R22的替代制冷剂R407C及R410A的介绍课件.ppt
- R3131A 频谱分析仪操作简介课件.ppt
- R92723030 沈子乔R92723037 陈禹君R92723049 蔡少怀课件.ppt
- Radiation Safety in Sentinel Node Biopsy Procedures课件.ppt
- Radio Regulatory Department of MII, China课件.ppt
- RAMP GoldParLab InfiniCore Model课件.ppt
- RBL-基于资源式的学习课件.ppt
- RC串联电路暂态过程的研究课件.ppt
文档评论(0)