edited by
18,835 views
50 50 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.

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

3 Answers

Best answer
63 63 votes

Correct Option: B
Worst case for quick sort happens when $1$ element is on one list and $n-1$ elements on another list.

edited by
3 3 votes
If the pivot is chosen as the last position then there is a left recursive of size (n-1) or right recursive call of size 0.

1.Partition function->O(n)

2.T(n-1) time in left recursive call

3.T(1) time in right recursive call

Recurrence relation: T(n-1)+T(1)+cn

Option B is correct
0 0 votes
Quick sort worst case time complexity is n^2, when the array is sorted or almost sorted then Quicksort algorithm runs in O(n^2) time.

The recurrence relation for Quick sort worst case time complexity is

T(n) = T(n-1) + T(1) + cn.

Hence, B is Answer.
Answer:
Position:
Show:

Related questions

8 8 votes
6 6 answers
3.8k
3.8k views
Arjun asked Feb 27, 2025
3,797 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...
61 61 votes
9 answers 9 answers
29.1k
29.1k views
go_editor asked Sep 26, 2014
29,136 views
Let $P$ be quicksort program to sort numbers in ascending order using the first element as the pivot. Let $t_1$ and $t_2$ be the number of comparisons made by P for the i...
77 77 votes
5 answers 5 answers
16.8k
16.8k views
Misbah Ghaya asked Feb 13, 2015
16,764 views
Let a$_{n}$ represent the number of bit strings of length n containing two consecutive $1$s. What is the recurrence relation for $a_{n}$?$a_{n - 2} + a_{n - 1} + 2^{n - 2...
90 90 votes
10 answers 10 answers
43.7k
43.7k views
go_editor asked Sep 28, 2014
43,698 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...