The Gateway to Computer Science Excellence
0 votes
165 views
Consider a scenario of modified quick sort, where we have given an input sorted array A[1 .. . n], all elements of array are distinct and n >=3. Pivot is the median of set of 3 elements [First element, middle element, and last element]. What will be worst case time complexity of modified quick sort?

a.O($n^{2}$)
b.O(nlogn)
c.O($n^{2}$logn)
d.O(nloglogn)
in Algorithms by Active (1.7k points)
edited by | 165 views
0
It should be O(nlogn) in worst case because, selecting median as pivot means it will be always  placed at the middle after applying partition algorithm.
0
B is the correct option

Because for every split occur at the middle .

2 Answers

+1 vote
Worst case would be Θ($n^2$) because input array given is already sorted.
by (213 points)
0
i think O(nlogn) is right answer....
0 votes
B should be the correct option.
by (231 points)

Related questions

+1 vote
1 answer
4
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,271 answers
198,141 comments
104,783 users