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

solve each proportion 4/x+2=16/9
WILL CROWN BRAINLIEST!!!
Having fled religious intolerance in england, the puritans in massachusetts:
Which would be historical evidence when studying manifest destiny
Who composed the Rite of Spring? Ludwig von Beethoven Igor Stravinsky Scott Joplin Arnold Schoenberg
did the alien and sedition acts violate our first amendment
what's was The famous art work made famous by the Romans
Alice and Bob share some money in the ratio 7:5. Alice get £4 more than Bob. How much does Alice get?
what are the different methods to identify functions
You have just been approved for a 30 year 5.5% fixed home mortgage. The monthly payment that you qualify for is $879.32. Use the table provided to determine the