The Gateway to Computer Science Excellence
0 votes
125 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.6k points)
edited by | 125 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 (107 points)
0 votes
B should be the correct option.
by (149 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,648 questions
56,430 answers
195,214 comments
99,931 users