6 votes 6 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 ? $O(N)$ $O(\log N)$ $O(N^2)$ $O(1)$ Programming in C tbb-ds-2 + – Bikram asked Nov 26, 2016 • edited Aug 19, 2019 by Counsellor Bikram 787 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes as here only 100 elements are present which is constant , time taken is constant O(1) , answer don't depnds upon selection sort . Bikram answered Nov 28, 2016 • selected Aug 16, 2019 by Bikram Bikram comment Share Follow See all 17 Comments See all 17 17 Comments reply Show 14 previous comments Zaki Mustafa commented Jan 25, 2017 reply Follow Share so basically the correct answer is O(n^2)?? 0 votes 0 votes Bikram commented Jan 25, 2017 reply Follow Share 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 votes 1 votes Abhisek Tiwari 4 commented Oct 14, 2018 reply Follow Share @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 votes 2 votes Please log in or register to add a comment.
0 votes 0 votes O(1) Constant time Shivangi Verma answered Dec 23, 2016 Shivangi Verma comment Share Follow See all 0 reply Please log in or register to add a comment.