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 solar nebula was a
objects such as wool blankets and skills such as horsemanship among Plains Indian tribes are examples of the columbian exchange causing
list three political ideas from the original thirteen colonies that influenced American government​
what is the best thing to do to get money as a kid
What is an equivalent form of the function f(x) = x^2 +8x+15 that reveals the zeros of the function? A. y= (x-3)^2-5 B. f(x) = (x-3)^2-5 C. f(x) = (x+3)(x+5
Describe two ways assigning incorrect codes can affect society
Which equation is y=(x+3)^2 +(x+4)^2 rewritten in vertex form ?
Essay Question: Explain the theme of Romeo and Juliet and how it is developed throughout the play.
Please help me with this homework. I have to go to school tomorrow. 'Im too busy to do it.
To preserve _______, make sure that all sentences in a paragraph directly support the topic sentence. A. unity B. evidence C. tone D. point of view