Appended below is the code for Selection Sort. You really do not have to understand the details of the code. If this algorithm takes 4 seconds to sort an array of 8 elements. How much time in seconds will the same code take to sort an array of 24 elements?

Respuesta :

Answer:

12 seconds.

Step-by-step explanation:

Let t represent time taken by code to sort an array of 24 elements.

We have been given that an algorithm takes 4 seconds to sort an array of 8 elements. We are asked to find the time it will take for same code to sort an array of 24 elements.

We will use proportions to solve our given problem.    

[tex]\frac{\text{Time}}{\text{Array of elements}}=\frac{4}{8}[/tex]

[tex]\frac{t}{24}=\frac{4}{8}[/tex]

[tex]\frac{t}{24}\cdot 24=\frac{4}{8}\cdot 24[/tex]

[tex]t=\frac{4}{1}\cdot 3[/tex]

[tex]t=12[/tex]

Therefore, it will take 12 seconds for the same code to sort an array of 24 elements.

ACCESS MORE
EDU ACCESS