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

What form of energy transformation occurs when wind spins turbines??
Congratulations! you have installed linux as your first vm. the gui is nice and you'll get the feel for it quickly (unless you already have it!). you will becom
Select the point that satisfies y ≤ x2 - 5x + 6. A. (1,1) B. (4,4) C. (2,2) D. (3,3)
Which statement implies that A and B are independent events? And the answers are: P(B|A) = P(B A) P(B|A) = P(B) P(A) P(B|A) = P(A) P(B|A) = P(B)
What is the relationship between the center of any circle and the point that lie on the circle?
what is an animal that has 4 legs?
whis is the oppossite of sloppily
what did many families do in ancient Rome when they had no son to carry on the family name
What are some Judeo-Christian values?
Determine the speed, wavelength, and frequency of light from a helium-neon laser as it travels through zircon. the wavelength of the light from the laser is 632