In: Computer Science
How can I prove that finding the minimum or maximum of n numbers has a lower bound of Ω(n) for any comparison-based algorithm.
Finding minimum or maximum element of an array requires (n-1) comparisons, we compare each element of the set of numbers in turns and keep track of the minimum or maximum, this requires (n-1) comparisons. We can't do better than (n-1) comparisons as we have to check each number with the minimum or maximum number of the rest of the numbers at least once.
PROOF:
Suppose a set of m elements requires x number of comparisons to find the minimum or maximum. Thus (m-1) numbers require (x-1) comparisons to find the minimum or maximum. By induction we can say that {m-(m-2)}= 2 numbers require {x-(m-2)} comparisons.
we know that x-m+2=1 => x=m-1
Thus the lower bound for finding the minimum or maximum would require m-1 comparisons for m numbers.
CONCLUSION:
Hence we know that for some positive constant C>0 say C=0.5; C*n <= (n-1) for all n >=2. Thus finding the minimum or maximum of n numbers has a lower bound of Ω(n) for any comparison-based algorithm.