Types
Lower Bounds for Sorting Algorithms
Consider any sorting algorithm that operates by comparing elements in the input array. The algorithm can be thought of as a comparison (or decision) tree. The depth of the binary tree gives us the max number of comparisons that could be required to sort. The number of possible orderings is the number of leaf nodes in the tree .
If there are permutations, a correct sorting algorithms needs to distinguish all permutations so .
A binary tree of depth has at most total nodes in the tree and at most leaves. To fit all permutations, . By lower bounding , and doing log math we can prove that any comparison-based sorting algorithm has a worst-case depth of .