The minimum number of comparisons required to sort 5 elements is -
Minimum number of comparisons = ⌈ log (n!)⌉ = ⌈log(5!)⌉ =⌈log(120)⌉ = 7Ref:http://en.wikipedia.org/wiki/Comparison_sort#Number_of_comparisons_required_to_sort_a_list
That is Sterling's approximation.
This is actual conversion:
log 2 ( n ! ) = n log 2 n − ( log 2 e ) n + O ( log n ) = Ω ( n log 2 n ) .
https://gateoverflow.in/95725/algorithm-minimum-comparison-sorting#a95826
minimum number of comparison is= log(n!)
so, ceil(log(n!))= ceil(log(nn)
=>ceil(log(nn))= ceil(nlog(n))
=>ceil(5log(5))= 4 which is option a
consider a discrete variate x which implies the number of elements in the array. Now either the elements can either be sorted or unsorted, hence probablity is ½
x= 1 2 3 4 5
p= ½ ½ ½ ½ ½
hence expected mean or expected number of comparisons= 1(1/2) +2(1/2) + 3(1/2) + 4(1/2) + 4(1/2) = 7(approx)
Thus around 7 comparisons required
64.3k questions
77.9k answers
244k comments
80.0k users