edited by
16,113 views
46 votes
46 votes

Consider the Quicksort algorithm. Suppose there is a procedure for finding a pivot element which splits the list into two sub-lists each of which contains at least one-fifth of the elements. Let $T(n)$ be the number of comparisons required to sort $n$ elements. Then

  1. $T(n) \leq 2T(n/5) + n$

  2. $T(n) \leq T(n/5) + T(4n/5) + n$

  3. $T(n) \leq 2T(4n/5) + n$

  4. $T(n) \leq 2T(n/2) + n$

edited by

4 Answers

Best answer
46 votes
46 votes

$T(n) \leq T(n/5) + T(4n/5) + n$

One part contains $n/5$ elements and the other part contains $4n/5$ elements $+n$ is common to all options, so we need not to worry about it.

Hence, the answer is option B.

edited by
12 votes
12 votes
The answer is B.

With 1/5 elements on one side giving T(n/5) and 4n/5 on the other side, giving T(4n/5).

and n is the pivot selection time.
3 votes
3 votes

Those who are confused between B and C .One thing is sure,If B is correct then C is also correct.

i.e,if  T(n)<=T(n/5)+T(4n/5)+n; implies T(n)<2T(4n/5)+n.

Hence,here We will chosse TIGHTEST-BOUND i.e.

Option:B

0 votes
0 votes
If you create two list containing 1/5th elements and in other it contains rest of the elements. If you go through the pivot elements it should give you recurrence relation

T(n) = T(n/5) + T(4n/5) + n

So option B is correct.
Answer:

Related questions

26 votes
26 votes
2 answers
2
Kathleen asked Sep 12, 2014
13,662 views
If a class $B$ network on the Internet has a subnet mask of $255.255.248.0$, what is the maximum number of hosts per subnet?$1022$$1023$$2046$$2047$
70 votes
70 votes
5 answers
4
Kathleen asked Sep 12, 2014
13,849 views
Let $\text{fsa}$ and $\text{pda}$ be two predicates such that $\text{fsa}(x)$ means $x$ is a finite state automaton and $\text{pda}(y)$ means that $y$ is a pushdown autom...