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

If y=-4 when x=10, determine y when x=5
what is 2,852.1 rounded to the nearest tenths
Together, tom and max have 72 football cards. Tom has 2 more than 4 times as many cards as Max has. How many football cards does tom have?
During the bitter struggle over reconstruction policy, Congress overrode Johnson's veto of the
What does "sometimes lies were more dependable than truth." mean?
Two cars leave a town at the same time heading in opposite directions. One car is traveling 12 mph faster than the other. After 2 hours, they are 232 miles apar
what is the square root of 2500????
suma a trei numere este 3932/Primul numar este cu 1330mai mare decat al doilea si cu 1740mai mare decat al treilea determinati cele trei numere vreau rezolvar
15 is 25% of what number
When you sneeze, the air in your lungs accelerates from rest to approximately 150km/h in about 0.50 seconds. What is the acceleration, in units of g?