![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
alogrithms
sunwenjun
这个作者很懒,什么都没留下…
展开
-
Heapsort
MAX-HEAPIFY(A, i) 1 l ← LEFT(i) 2 r ← RIGHT(i) 3 if l ≤ heap-size[A] and A[l] > A[i] 4 then largest ← l 5 else largest ← i 6 if r ≤ heap-size[A] and A[r] > A[largest] 7 then largest ← r 8 i原创 2007-05-25 00:16:00 · 645 阅读 · 0 评论 -
Introduction to Alorithms
INSERTION-SORT(A)1 for j ← 2 to length[A]2 do key ← A[j]3 ▹ Insert A[j] into the sorted sequence A[1 ‥ j - 1].4 i ← j - 15 while i > 0 and A[i] > key6 do原创 2007-05-24 08:32:00 · 672 阅读 · 0 评论 -
合并排序及堆排序
MERGE-SORT(A, p, r)1 if p 2 then q ← ?(p + r)/2?3 MERGE-SORT(A, p, q)4 MERGE-SORT(A, q + 1, r)5 MERGE(A, p, q, r)其主要递归思想是:对于每个子任务分为先排左边的,然后排右边的,最后联合起来排序。其算法复杂度:T(n)=2 if n=2原创 2007-05-31 13:15:00 · 771 阅读 · 0 评论