1.0062 Given a list of 41 elements, what is the maximum number of comparisons needed? How does this contrast with a bubble sort?
The maximum number of comparisons needed in a quicksort is (ceiling of) log2 n! =
(ceiling of) log2 41! = (ceiling of) log2 8.159E47 = (ceiling of) 159.16 = 160
The maximum number
of comparisons needed in a bubble sort is (n2
– n)/2 =
(412 – 41)/2 = (1682 – 41)/2 = 1640/2 = 820