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

Experts agree that the minimum time period for cardiorespiratory benefit from exercise is _______ minutes.      A. 20B. 10C. 60D. 30
89.36 rounded to the ones place
Which passage is chronological???
What is the value of x?
Is Charles David Waller in WW1
how a convection current can enable a hawk or eagle to soar upward without flapping its wing
Why did the British Monarchy's believe that they had a right to tax the colonies in order to help finance the French and Indian War?
Find each sum or difference? Do u just work the problem out and put the answer down?
What does your text mean when it says that the Constitution, "...elevated the ideals of the Revolution even while setting boundaries to them."?
Divide 33 photos into two groups so the ratio is 4:7. How do you properly write the answer? 4 7 4 7 4 7 4+4+4=12 7+7+7=21 12+21=33 Is th