in Algorithms edited by
4,547 views
0 votes
0 votes

Which of the following input will give best case time for selection sort?

(A) 1 2 3 4 5 6 7 8 9 10

(B) 2 3 1 5 9 7 8 6 10

(C) 10 9 8 7 6 5 4 3 2 1 

(D) All of above take same amount of time

in Algorithms edited by
4.5k views

3 Comments

D?

as all the best, worst and average case time complexity of selection is O(n^2).
0
0
But in the option B , there are only 9 elements where as both A and C has 10 elements.
1
1
Selection sort has time complexity of O(n^2) for both best and worst case.

So answer is D.
0
0

1 Answer

0 votes
0 votes
Option D) All take same time as Complexity of Selection sort in every case is O(n^2)

Related questions