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

1. Noah has $15,000 to invest. He invests some amount at 5% annual interest and the rest at 3% annual interest. After one year, his total interest from both acc
Simplify fully 8xz3/20x2y2​
Solve the logarithmic equation. Be sure to reject any value of x that is not in the domain of the original logarithmic expressions. Give the exact answer In (x
Please help me with this
Sally, John & Mary had a discussion about Quadrilateral PQRS. Sally claimed that the figure represents an isosceles trapezoid, John claimed that it is a non
the nearest ten 11,150 is 11,348 rounded to the nearest ten. nearest thousand 11,100 is 11,348 rounded to the nearest thousand. explain how you rounded these nu
The unjust system of apartheid ruled South Africa for more than 40 years. In your own words, write a paragraph of at least five sentences explaining the goals o
Can someone answer this for me? 1/2a=11 a=?
what is 3 2/6 - 2/3??
Evaluate three communication skills that can assist you in sustaining positive relationships​