recategorized by
524 views

2 Answers

0 votes
0 votes
At first if you consider master theorem only, it may happen that option D seems to be true.

 

but recall worst case complexity of quick sort arises only when partitions are unbalanced (skewed)

therefore option B is the answer.
0 votes
0 votes

Answer is option B,

Worst case occurs in Quick sort when array is either in increasing order or in decreasing order.

Eg. Increasing : [1,2,3,4,5] , decreasing: [5,4,3,2,1]

Recurrence relation of quicksort ,

T(n) = T(k-1) + T(n-k) + O(n)

Case 1] Increasing order:

At that situation pivot always fall at first position of partition ,

Therefore, recurrence relation will be ,

T(n) = T(0) + T(n-1) + O(n) ... (Put k=1)

         =O(n^2)

 

Case 2] decreasing order , 

At this situation the pivot always fall at last of partition,

Therefore recurrence relation will be ,

T(n) = T(n-1)+T(0)+O(n) ... (Put k=n)

         =O(n^2)

Answer:

Related questions

1 votes
1 votes
0 answers
1
gatecse asked Dec 9, 2020
391 views
Given $r_{12}=0.6, r_{13}=0.5$ and $r_{23}=0.8,$ the value of $r_{12.3}$ is :$0.47$$0.40$$0.74$$0.64$
1 votes
1 votes
1 answer
3
gatecse asked Dec 9, 2020
668 views
Which of the following is a correct time complexity to solve the $0/1$ knapsack problem where $n$ and $w$ represents the number of items and capacity of knapsack respecti...
1 votes
1 votes
1 answer
4
gatecse asked Dec 9, 2020
407 views
Finding the location of the element with a given value is :TraversalSearchSortNone of the options