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 Algorithms made-easy-test-series algorithms sorting + – srestha asked May 6, 2019 • retagged Jun 30, 2022 by makhdoom ghaya srestha 454 views answer comment Share Follow See 1 comment See all 1 1 comment reply Aditya Patel commented May 6, 2019 reply Follow Share 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 votes 1 votes Please log in or register to add a comment.
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 Aditya Patel answered May 6, 2019 • selected May 6, 2019 by srestha Aditya Patel comment Share Follow See all 2 Comments See all 2 2 Comments reply Devg123 commented May 8, 2019 i moved by srestha Nov 18, 2019 reply Follow Share Answer is 5000*4 0 votes 0 votes SaurabhKatkar commented Nov 18, 2019 i moved by srestha Nov 18, 2019 reply Follow Share Yes it is 4*5000 0 votes 0 votes Please log in or register to add a comment.