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

how to write an equation and solve it for the followingOne fifth of the employees of Delta Industries, Inc., work in the Sotheastern region. If the company empl
What is HIV and the causes
Locate the gerund and identify its use.Wrestling alligators seems both foolish and dangerous.
A pack of 9 toilet rolls costs £4.23 A pack of 4 toilet rolls costs £1.96 Which pack gives the better value for money? You must show all your working.
Explain why the current is reduced as electrons move through a conductor.
What is HIV and the causes
A certain test is worth 155 points. How many points (rounded to the nearest point) are needed to obtain a score of 65%?
what describes the solvent in any solution
Determine the half-life of potassium if in 3460 years a 200 g sample decayed into 25 g
whats Henry Hudson interesting facts?