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

I was the MVP of Super Bowl XLI. I attended the University of Tennessee and play the position of quarterback. Who am I?
what is qualitative and quantitive data?
2cos^2x+sinx=2 domain restriction 0,2pi
Name TWO duties of the crane operator.
Which of the following types of models would be most effective to demonstrate the relationship between distance and time?
Madagascar (Lesson 06.01) •Which one of the following different creepy crawlers would you likely not discover when exploring the Madagascan forest? – giant hi
Which igneous rock has large crystals surrounded by smaller crystals
what physical property makes metal pots good for cooking?
Help! Donovan runs about 2.5 miles each day. In 3 weeks, about how many miles does he run?
what did stone age people wear?