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

MATH PLEASE HELP! A square field has an area of 479² ft What is the approximate length of a side of the field? Give your answer to the nearest foot. Explain you
HELP PLEASE ASAP Crosswater = CSW United states dollars = USD 1 USD = 20 CSW You have $100 in the United States. Imagine you are visiting Crosswater to check
Why were the Vikings able to do so much exploration during their time?​
Nose bleeding occurs as we move towards high altitude, why?
what is the rate of change between the point (0,0)and (2,100)
Simplify 4(6 - 2x) - 3(3 - 4x) 4x + 15 15 - 20x 15 - 6x
Hiiiii everybody!!!!!!!!!!!!
How is an emulsion different from other colloids?
Can you please help me ?​
What is 11/20 as a decimal and as a representation percent? Please answer fast thank you