网站大量收购独家精品文档,联系QQ:2885784924

Merge Sort.ppt

  1. 1、本文档共22页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Merge Sort.ppt

Merge Sort * Analysis of Merge-Sort The height h of the merge-sort tree is O(log n) at each recursive call we divide in half the sequence, The overall amount or work done at the nodes of depth i is O(n) we partition and merge 2i sequences of size n/2i we make 2i+1 recursive calls Thus, the total running time of merge-sort is O(n log n) depth #seqs size 0 1 n 1 2 n/2 i 2i n/2i … … … Merge Sort * Summary of Sorting Algorithms Algorithm Time Notes selection-sort O(n2) slow in-place for small data sets ( 1K) insertion-sort O(n2) slow in-place for small data sets ( 1K) heap-sort O(n log n) fast in-place for large data sets (1K — 1M) merge-sort O(n log n) fast sequential data access for huge data sets ( 1M) Merge Sort * * * * * Merge Sort ? 2004 Goodrich, Tamassia ? 2004 Goodrich, Tamassia Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort Merge Sort * Merge Sort 7 2 ? 9 4 ? 2 4 7 9 7 ? 2 ? 2 7 9 ? 4 ? 4 9 7 ? 7 2 ? 2 9 ? 9 4 ? 4 Merge Sort * Divide-and-Conquer (§ 10.1.1) Divide-and-conquer (分治演算法) is a general algorithm design paradigm: Divide: divide the input data S in two disjoint subsets S1 and S2 Conquer: solve the subproblems associated with S1 and S2 Combine: combine the solutions for S1 and S2 into a solution for S The base case for the recursion are subproblems of size 0 or 1 Merge-sort is a sorting algorithm based on the divide-and-conquer paradigm Like heap-sort It uses a comparator It has O(n log n) running time Unlike heap-sort It does not use an auxiliary priority queue It accesses data in a sequential manner (suitable to sort data on a disk) External sort 化整為零 各個擊破 Merge Sort Merge sort A divide and conquer algorithm Invented by John von Neumann in 1945 Merge Sort * 約翰·馮·紐曼(John von Neumann,1903年12月28日-1957年2月8日),出生於匈牙利的美國籍猶太人數學家,現代電腦創始人之一。他在電腦科學、經濟、物理學中的量子力學及幾乎所有數學領域都作過重大貢獻,被譽為「電腦之父」。(圖及說明摘自維基百科) Merge Sort * Merge-Sort (§ 10.1) Merge-sort on an input seque

文档评论(0)

gshbzl + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档