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

maria's math test had 25 questions she got 84% correct how many did she get wrong
2 pounds of potatoes are taken out of the bag what weight does the scale show now
Once someone has a sensory cell, they have that cell for life.   Please select the best answer from the choices provided T F
A successful biologist’s main interest area would be _____. a. the 21 b. scientific c. 4 d. social
will a change in the frequency of sound affect its speed?
True or False:If the price of a product goes up by 10% and the quantity demanded goes up by 20% the product is an inferior good.
$350 at 3% for 10 years
Where are Baltic-Slavic languages spoken? A. northern Europe B. eastern Europe C. western Europe D. southwestern Europe
6 stools and 4 chairs cost $58 but 5 stools and 2 chairs cost $35 find the coast of each stool and each chair
help please picture above really easy question