in Programming edited by
360 views
5 votes
5 votes

A sorting technique is called to sort a list of $100$ integers that have been read from a file. If all $100$ values are zero, what would be the execution requirement(in terms of Big -O) if the sort used was selection sort ?

  1. $O(N)$
  2. $O(\log N)$
  3. $O(N^2)$
  4. $O(1)$
in Programming edited by
by
360 views

2 Answers

0 votes
0 votes
Best answer
as here only 100 elements are present which is constant ,  time taken is constant O(1) , answer don't depnds upon selection sort .
selected by

4 Comments

so basically the correct answer is O(n^2)??
0
0
No, basically answer is O(1)

read above comments.

It will be O(n) if n is not known.. but here only 100 elements are present which is constant.. so time taken is constant O(1) ..

And whether its selection sort or any other sorting technique, since you take only 100 integers, its O(1).

@zaki
1
1

@Bikram sir 

Sir if n is unknown it will be O(n2) not O(n),As best case of selection sort is also O(n2).

see https://en.wikipedia.org/wiki/Selection_sort

2
2
0 votes
0 votes
O(1) Constant time
Answer:

Related questions