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

Inalienable in a sentence
What year came after 184 B.C?
What effect do you think the Pyrenees, Alps, & Carpathian Mountains had on life in medieval Europe?
Find the missing number in the patter explain your reasoning 12,24,72,288
What value is the 9s in 299?
"My sister's friend Ana plays soccer". what is the complete subject and the Simple Subject
How were the indigenous peoples of Australia affected by the British takeover? a. The British moved most of the indigenous peoples onto lands with poor quality
What was the Enlightenment?
sentence for indentured servant
what is 7 times the square root of 96m^3