摘要: Chapter 6: HeapsortChapter 6: HeapsortOverviewIn this chapter, we introduce another sorting algorithm. Like merge sort, but unlike insertion sort, heapsort's running time is O(n lg n). Like insertion sort, but unlike merge sort, heapsort sorts in place: only a constant number of array elements a 阅读全文
posted @ 2010-11-10 10:44 Mose 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 2.3.1 The divide-and-conquer approachmerge sortMERGE(A, p, q, r)1 n1 ← q - p + 12 n2 ← r - q3 create arrays L[1 ‥ n1 + 1] and R[1 ‥ n2 + 1]4 for i ← 1 to n15 do L[i] ← A[p + i - 1]... 阅读全文
posted @ 2010-11-10 08:34 Mose 阅读(156) 评论(0) 推荐(0) 编辑