edited by
24,751 views
61 61 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$

5 Answers

Best answer
56 56 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
2 flags:
✌ Low quality (Anurag Prasad “Poor explanation”)
✌ Edit necessary (sandeshrbhat24)
16 16 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.
10 10 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

3 3 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.
2 2 votes

Answer: (B) — T(n)≤T(n/5)+T(4n/5)+n.

Reason : pivot guarantees both parts have at least n/5 elements, so the two subproblems have sizes between n/5 and 4n/5. The worst split (for recurrence) is one of size ⌊n/5⌋ and the other ⌊4n/5⌋. 

Add linear-time partitioning work Θ(n), giving

T(n)≤T(n/5)+T(4n/5)+Θ(n).

With this bound the total cost is Θ(nlog⁡n) since each level costs Θ(n) and depth is O(log⁡n).

Answer:
Position:
Show:

Related questions

8 8 votes
6 6 answers
3.8k
3.8k views
Arjun asked Feb 27, 2025
3,814 views
Suppose that insertion sort is applied to the array $[1,3,5,7,9,11, x, 15,13]$ and it takes exactly two swaps to sort the array. Select all possible values of $x$.$10$$12...
74 74 votes
4 answers 4 answers
35.1k
35.1k views
Kathleen asked Sep 12, 2014
35,080 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...
50 50 votes
3 answers 3 answers
18.9k
18.9k views
Misbah Ghaya asked Feb 11, 2015
18,864 views
Which one of the following is the recurrence equation for the worst case time complexity of the quick sort algorithm for sorting $n\;( \geq 2)$ numbers? In the recurrenc...
90 90 votes
10 answers 10 answers
43.8k
43.8k views
go_editor asked Sep 28, 2014
43,794 views
You have an array of $n$ elements. Suppose you implement quicksort by always choosing the central element of the array as the pivot. Then the tightest upper bound for the...