What does cn indicates ?

The Gateway to Computer Science Excellence

+25 votes

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 recurrence equations given in the options below, $c$ is a constant.

- $T(n) = 2 T (n/2) + cn$
- $T(n) = T ( n - 1) + T(1) + cn$
- $T(n) = 2T ( n - 1) + cn$
- $T(n) = T (n/2) + cn$

+30 votes

Best answer

+6

But according to Cormen, worst case for Quicksort algo occurs when the partitioning produces one subproblem with n-1 elements and another with zero elements ( the nth element is the pivot which gets added to the end of the first subproblem). In fact, it states that even a partition with a 9:1 proportional split also runs in O(n lg n) time.

+3

Yes. n-1 elements on one list- 0 on other list is because 'pivot' is ignored- which is anyway placed.

0

For Worst Case correct Recurrences are:

$\mathbf{T(n) = T(0) + T(n-1) + \theta (n)}$

which is the same as:

$\mathbf{T(n) = T(n-1) + \theta (n)}$

The solution of this recurrence is $\mathbf{\theta (n)}$

Maybe the examiner have something to do with $\mathbf{n \ge 2}$ case. If this isn't the case, then the options are definitely wrong $\color{blue} {\text{According to Cormen and Wikipedia.}}$

$\mathbf{T(n) = T(0) + T(n-1) + \theta (n)}$

which is the same as:

$\mathbf{T(n) = T(n-1) + \theta (n)}$

The solution of this recurrence is $\mathbf{\theta (n)}$

Maybe the examiner have something to do with $\mathbf{n \ge 2}$ case. If this isn't the case, then the options are definitely wrong $\color{blue} {\text{According to Cormen and Wikipedia.}}$

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.4k
- Admissions 595
- Exam Queries 573
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,741 questions

57,252 answers

198,061 comments

104,697 users