360 views

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)$

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

so basically the correct answer is O(n^2)??

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

@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).

O(1) Constant time