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 special molecule which is able to store and recover information about genetic traits is
Hi! can you please help with this
In the figure shown , which is the value of y?
which of the following information would be included in a style manual? the proper format for citing sources a historical timeline a glossary of terms used in l
Choose the correct answer below.4/32/33.14cylinderspherePut your answer of the space/blank.1. the volume of a sphere is _____ to the volume of cylinder.2. the v
give 5 numbers smaller than -2 and 5 numbers bigger than -2​
what is the volume of a tissue box with 1 ft x 2 ft x 3 ft ?
necesito esto ayuda !!!
7. Hyperventilating will decrease respiration rate. Why?
Line JK passes through J(2,7) and K(5, 11). What is the slope of line JK? Helppp