retagged by
454 views
0 votes
0 votes

Through an experiment, it is found that selection sort performs $5000$ comparisons when sorting an array of size $k.$ If the size of array is doubled, what will be the number of comparisons?


will it be $\left ( 5000 \right )^{2}$ or $\left ( 5000 \right )\times 4$. Someone check plz

retagged by

1 Answer

Best answer
1 votes
1 votes
The answer will be (5000)×4.

# Of Comparison = O(n^2) so ,

5000 = C (k^2) [Where C is asymptotic constant ]

so C= 5000 / (k^2)

Now if we double the element so n=2k

# Of Comparison = C [(2k)^2]

                            = 4 * C * (k^2)

                            = 4 * [5000 / (k^2)] * (k^2)

                            = 4*5000
selected by

Related questions

1 votes
1 votes
5 answers
3
hitesh159 asked Apr 16, 2019
2,109 views
why not merge sort?we don’t swap in merge sort,we just create auxillary arrays and merge them by changing elements in the original array.should we consider that as a sw...
0 votes
0 votes
1 answer
4
Arnabi asked Jan 7, 2017
360 views