今天我在阅读Julienne Walker关于排序的一篇优秀文章 - Eternally Confuzzled - The Art of Sorting,其中有一点引起了我的注意。我不太理解作者证明用比较进行排序时,我们受到Ω(N·log N)下限的限制部分。
Lower bounds aren't as obvious. The lowest possible bound for most sorting algorithms is Ω(N·log N). This is because most sorting algorithms use item comparisons to determine the relative order of items. Any algorithm that sorts by comparison will have a minimum lower bound of Ω(N·log N) because a comparison tree is used to select a permutation that's sorted. A comparison tree for the three numbers 1, 2, and 3 can be easily constructed:
1 < 2 1 < 3 1 < 3 2 < 3 3,1,2 2,1,3 2 < 3 1,2,3 1,3,2 2,3,1 3,2,1
Notice how every item is compared with every other item, and that each path results in a valid permutation of the three items. The height of the tree determines the lower bound of the sorting algorithm. Because there must be as many leaves as there are permutations for the algorithm to be correct, the smallest possible height of the comparison tree is log N!, which is equivalent to Ω(N·log N).
这篇文章看起来非常合理,直到最后一部分(加粗的内容),我不太理解——如何将log N!等价于Ω(N·log N)。我可能在我的计算机科学课程中遗漏了什么,无法理解最后的过渡。我期待着对此进行帮助,或者提供其他证据的链接,以证明如果我们使用比较排序,我们受到Ω(N·log N)的限制。