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

The single factor that is changed in an experiment is the __________. dependent variable control hypothesis independent variable
could a mixture be made up of only elements and no compounds? explain.
3x+4y=2 4x-4y=12 elimination
Which one of the following lines is written in iambic pentameter? A. "And sorry I could not travel both" B. "When the proofs, the figures, were ranged in column
find two consecutive odd integers whose sum is 72
How do I find the ratio of the first measurement to the second measurement ? Problem: Length of a tennis racket: 2 ft. 4 in. Length of a table tennis table pad
why did they choose the location of mission san Fernando?
Write the equation in slope-intercept form. 2/3(6y+9)=3/5(15x-20)
What is 5/12 divided by 3/16 as a fraction?
There are 200 paperweights in a box. The mass of each paperweight is 0.085 kilogram. The mass of the empty box is 560 grams. What is the total mass of the box a