Linear Time Selection[An Ω(nlogn) Sorting Lower Bound]

Theorem: 

every "comparison-based" sorting algorithm has worst-case running time  Ω(nlogn).

Comparison-Based sort: 

accesses input array elements only via comparisons

Examples: 

MergeSort, QuickSort, HeapSort

Proof idea:

Fix a comparison-based sorting method and an array length n.

Consider input arrays containing {1,2,3...n} in some order. So there are n! such inputs.

Suppose algorithm always makes ≤k comparisons to correctly sort these n! inputs.

across all n! possible inputs, algorithm exhibits ≤2^k distinct executions.[由于最多只比较k次,这里针对任意一种情况,该算法最多有2^k种比较的可能]

By the pigeonhole principle: if 2^k<n!, execute identically on two distinct inputs. So there must get one of them incorrect.[如果2^k<n!,那么就会存在两个不同的输入,他们的比较过程居然是一样的,显然其中一个处理得到的结果是错的]

So, since method is correct, 2^k≥n!≥(n/2)^(n/2), so k≥(n/2)log2(n/2)=Ω(nlogn). [这里用了放缩法,把n!换为了(n/2)^(n/2),从而验证了这个结论]

 

你可能感兴趣的:(Algorithm)