Answer D
Explanation
A maximum depth path always takes the larger part of partition
- In question given that always β <=0.5
- So maximum partition will be (1-β ) n
We have to find maximum depth d, means how many times quick sort loop will be executed!!
- One iteration splits the number of elements from n to (β n ) and (1-β)n
- So i iterations reduces the number of elements to β i n and (1-β) i n .
At a leaf, there is just one remaining element,
In case of maximum depth path ( let maximum depth be d)
(1-β)d n = 1
(1-β)d = 1/n
Take logarithm on both sides,
d log ( 1-β) = -log n
d = -log n/log ( 1-β)
- Similarly we can find minimum depth d' = -log n/log β