bbyitskeke9967 bbyitskeke9967
  • 03-02-2020
  • Computers and Technology
contestada

Given an n-element array X, algorithm D calls algorithm E on each element X[i]. Algorithm E runs in O(i) time when it is called on element X[i]. What is the worst-case running time of algorithm D?

Respuesta :

mateolara11
mateolara11 mateolara11
  • 05-02-2020

Answer:

O(n^2)

Explanation:

The number of elements in the array X is proportional to the algorithm E runs time:

For one element (i=1) -> O(1)

For two elements (i=2) -> O(2)

.

.

.

For n elements (i=n) -> O(n)

If the array has n elements the algorithm D will call the algorithm E n times, so we have a maximum time of n times n, therefore the worst-case running time of D is O(n^2)  

Answer Link

Otras preguntas

Someone please help me
what stage of the cell cycle happens last?
If A2 = A, which matrix is matrix A?Picture attached
Who does the President work with in the Cabinet when creating a treaty with another country? A Secretary of Urban affairs B Secretary of State C None of t
If two genes show nearly 100 percent linkage, what does that tell us? Select all that apply. a) The two genes are on separate chromosomes. b) The two genes are
A bird is flying with through the air with a speed of 18.0 m/s. As it flies, it holds in its claws a 2 kg fish that it just caught moments ago. Suddenly, the fi
How would the gravity change if the earth was farther away fro maybe sun?
what is −5x+2y=9 y=7x ​
Find the mean, median and mode of these numbers11,10,8,10,1 12,10,16,28,15,29,26,16,113,11,12,8,10,69,12,5,9,14,5,7,8,9,2Thank you for helping!​
What would happen if there were no condensation stage in the water cycle?