A sorting algorithm takes 1 second to sort n =1000 items.

1) How many operations will be performed if the sorting algorithm is O(n2) (approximately)?

2) How long will it take to sort 10,000 items if the sorting algorithm is O(n2)?

3) How much time will one operation take if the sorting algorithm is O(n2)?

Respuesta :

Answer:

1.1,000,000,

2, 1 minute 40 secs

3.10^-6 secs

Step-by-step explanation:

sorting algorithm takes 1 second to sort n =1000 items.

1) How many operations will be performed if the sorting algorithm is O(n2) (approximately)?

2) How long will it take to sort 10,000 items if the sorting algorithm is O(n2)?

3) How much time will one operation take if the sorting algorithm is O(n2)?

algorithm takes time proportional to n^2,

1. then 1,000^2=1,000,000,

2. if it takes 1 secs to generate 1000 items

yhen n^2=1000^2=1000000  and 10,000^2=100,000,000.

Dividing  by  100. Therefore, the sorting algorithm would take

1 minute and 40 seconds to sort 10,000 items.

3. How much time will one operation take if the sorting algorithm is O(n2)?

1/1000^2

10^-6 secs to sort 1 operations