+1 vote
323 views

You have an array of n  elements. Suppose you implement quick sort by always choosing the central element of the array as the pivot. Then the tightest lower bound for the best case performance is

a) O(n2)

b) O(nlogn)

c) Θ(nlogn)

d) O(n3)

| 323 views
+4

Best : $\Omega \left ( nlogn \right )$  worst = O(n2)

0

In best case upper bound will be O(n2)?

0
It is normal quick sort in which we are selecting the middle element as the pivot so the best case will be that it is divided into two equal parts giving the time complexity of O(nlogn).

In the worst case the it will take O(n^2) as the middle element selected can divide the array into two parts of  0    element at one side and n-1 at other.

now in the question it is asking for the lower bound in the best case.

the time complexity in best case is O(nlogn)

now tightest lower bound means the least possible time in which the problem can be solved.

in this case tightest lower bound is O(nlogn).

best case= o(nlogn)

If we choose central element as pivot then array is divided into two equal part. And recurrence relation become T(n)=2T(n/2)+n which will take o(nlogn) time.

Worst case  =o(n^2).

If we choose central element as pivot then array is divided into two part one part contain 0 element and other part is n-1 element.  And recurrence relation become T(n)=T(n-1)+1 which will take o(n^2).

by Boss (35.6k points)
selected by
0
Worst case recurrenct relation is T(n) = T(n-1) + n not T(n) = T(n-1) + 1. According to your recurrence relation, time complexity will become O(n).