随笔分类 - Introduction.to.Algorithms
读书笔记
摘要:2-1 Insertion sort on small arrays in merge sortAlthough merge sort runs in(n lg n) worst-case time and insertion sort runsin(n^2) worst-case time, the constant factors in insertion sort make it faster forsmall n. Thus, it makes sense to use insertion sort within merge sort when subprob-lems become
阅读全文
摘要: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
阅读全文
摘要: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]...
阅读全文

浙公网安备 33010602011771号