666 views
1 votes
1 votes
Q.  In Quick sort ,for sorting n element ,the (n/4)th smallest element is selected as pivot using an O(n) time algorithm. What is the worst case tome complexity of the Quick sort?

a) O(n)

b) O(nlogn)

c) O(n2)

d) O(n2logn)

1 Answer

0 votes
0 votes

 (n/4)th smallest element is selected as pivot using an O(n).

n/4th smallest element will divide the array into two parts, one part will have 1/4th elements at LHS of pivot element (pivot element can be considered a part of LHS), and second part will have 3/4th elements at RHS of pivot element. As pivot element goes to its correct position every time.
We'll get following recurrence relation:
T(n) = T(n/4) + T(3n/4) + n

Solve this recurrence relation and you will get T.C as $n*log_{4/3}^{n}$

Related questions

1 votes
1 votes
1 answer
1
0 votes
0 votes
1 answer
4
prateekdwv asked Mar 24, 2016
466 views
What is the solution of following recurrence relation.$B(2) = 1$$B(n) = 3B(n/\log_2(n))+\Theta(n)$​