in Algorithms retagged by
440 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

in Algorithms retagged by
by
440 views

1 comment

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
1
1

1 Answer

1 vote
1 vote
Best answer
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

2 Comments

moved by
Answer is 5000*4
0
0
moved by
Yes it is 4*5000
0
0

Related questions

0 votes
0 votes
1 answer
4
Arnabi asked in Algorithms Jan 7, 2017
352 views
Arnabi asked in Algorithms Jan 7, 2017
by Arnabi
352 views