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

subtract and round your answer to the nearest whole number 9-1.004
35 Given the word equation: sodium chlorate ==> sodium chloride + oxygen Which type of chemical reaction is represented by this equation? (1) double replacem
Britain, Australia, and France aided the United States in the war against Japan. a. True b. False
What two major Confederate cities were nearly burned to the ground late in the Civil War?
The Dust Bowl is a historical example of what? A. water erosion B. wind erosion C. rock weathering D. glacial erosion
What is the number? When I add 13 to it, the result is 9 less 32
Britain had a dream of building a railroad from the Mediterranean Sea to South Africa (i.e. from Cairo to Cape Town). Which country was in the strongest positio
does variation occur between different species?
what is the quotient of 11/12 ÷ 5/7 ?
If you were a specialist working for the National Security Agency, your main job would likely be a. analyzing data from spy satellites. b. working in the fiel