recategorized by
1,237 views
0 votes
0 votes

Suppose that the splits at every level of quicksort are in the proportion 1 - α to α, where 0 < α ≤ 1/2 is a constant. Show that the minimum depth of a leaf in the recursion tree is approximately - lg n/ lg α and the maximum depth is approximately -lg n/ lg(1 - α). (Don't worry about integer round-off).

how to procede with this problem i had seen stackoverflow solution but couldn’t understand 

https://stackoverflow.com/questions/17684680/maximum-and-minimum-depth-of-quicksort

recategorized by

1 Answer

1 votes
1 votes
The size of the array is $n$.

Applying $quick\,sort$

In the first step, the array splits into sizes : $n*\alpha$ and $n*(1-\alpha)$

as $0\leq\alpha\leq\frac{1}{2}$ so $n*(1-\alpha)$ is the greater part of array.

In the second step $n*\alpha$ will split into $n*\alpha^{2}$,  $n*\alpha*(1-\alpha)$ and $n*(1-\alpha)$ into $n*(1-\alpha)*\alpha$, $n*(1-\alpha)^2$

The maximum time to traverse $i.e.$ the $maximum\,depth$ will be when we keep taking the maximum part $i.e.$
$n*(1-\alpha)\rightarrow n*(1-\alpha)^2\rightarrow n*(1-\alpha)^3\rightarrow .....\rightarrow n*(1-\alpha)^k$

$n*(1-\alpha)^k=1, $taking $log$ both sides

$log(n)+k*log(1-\alpha)=0$

$k=\frac{-log(n)}{log(1-\alpha)}=maximum\,depth$

The minimum depth will be when we traverse through sizes
$n*\alpha \rightarrow n*\alpha^{2}\rightarrow ..... \rightarrow n*\alpha^k$

$n*\alpha ^k=1,$ taking $log$ both sides

$log(n)+k*log(\alpha)=0$

$k=\frac{-log(n)}{log(\alpha)}=minimum\,depth$

Related questions

528
views
0 answers
0 votes
akash.dinkar12 asked Jun 27, 2019
528 views
Banks often record transactions on an account in order of the times of the transactions, but many people like to receive their bank statements with checks listed in order...
1.7k
views
1 answers
0 votes
akash.dinkar12 asked Jun 27, 2019
1,748 views
What value of $q$ does PARTITION return when all elements in the array $A[p..r]$ have the same value? Modify PARTITION so that $q=\lfloor(p+r)/2 \rfloor$ when all element...
466
views
0 answers
1 votes
akash.dinkar12 asked Jun 28, 2019
466 views
A probability distribution function $P(x)$ for a random variable $X$ is defined by $P(x) =Pr\{X\leq x\}$.Suppose that we draw a list of $n$ random variables $X_1,X_2,…,...
1.6k
views
1 answers
0 votes
akash.dinkar12 asked Jun 27, 2019
1,586 views
PARTITION(A,p,r) 1 x = A[r] 2 i = p – 1 3 for j = p to r – 1 4 if A[j] <= x 5 i = i + 1 6 exchange A[i] with A[j] 7 exchange A[i+1] with A[r] 8 return i + 1 illustrat...