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

Explain the significance of the following line…""but the hunger games are their weapon and you are not supposed to be able to defeat it. ""
Please help due today
I don't understand this
When would a flag variable be most useful? 1.when printing the number of items in a list 2.when checking the condition of a variable in a while loop 3.inside a
Alannah, Colin and Hannah visit the park and collect conkers and acorns. In total they collect the same number of conkers and acorns. Alannah, Colin and Han
solve this system of equations using substitution, show your work (ANSWER QUICK PLEASE)
Can Someone Pls Help Me With This
Name at least two capital cities in south america that are located on an ocean
Which is NOT a characteristic of the temperate region? A. a lot of organic matter B. moderate temperatures C. moderate rainfall D. under-developed soil horizons
use the intersect method to solve the equation -2x+1=-x^2+4