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

The great Pyramids were A.Tombs for the pharoahs B. Tombs for the priests C.Temples to the gods D. Fortresses
Describe a situation that could be modeled with the ratio 4:1
Round 412,825 to the nearest ten
what 5000 is 1/10 of?
Are (121 over 11),(23 over 3), and (85 over 5) in simplest form?
How do you convert 0.4 repeating into a fraction?
If one-half of a number is 8 less than two-thirds of the number, what is the number?how? 1)24 2)32 3)48 4)54
Word form 67.943 answers please
Answer on this one please: the coastline of the United States is 12,383 miles long.canada's coastline is 113,211 miles longer than the coastline of United State
Write a pair of numbers such that the value of the 7 in the first number is 1000 times the value of the 7 in the second number, and the value of the 3 in the fi