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

Ow did the institution of slavery in england’s atlantic seaboard colonies differ from slavery in the caribbean? what accounted for these differences?
When elemental iron corrodes it combines with oxygen in the air to ultimately form red brown iron(iii) oxide which we call rust. (a) if a shiny iron nail with a
Why do you think a federal system replaced the confederal form of government that was first tried in the United States
You hire a printer to print concert tickets. He delivers them in circular rolls labeled as 1000 tickets each. You want to check the number of tickets in each ro
In Balboa what were the many references and images to dogs through the story?
what data show a proprotional relationship
A __________ is an example of an external user of financial information.
___ la nieve Me gusta Me gustan
How much would it cost to cover the entire us with dollar bills?
Find three consecutive even integers whose sum is 200 more than the smallest integer.