随笔分类 -  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 阅读全文
posted @ 2011-09-05 08:47 Mose 阅读(278) 评论(0) 推荐(0)
摘要: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 阅读(224) 评论(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 阅读(169) 评论(0) 推荐(0)