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

I costs $36 for 4 movie tickets, What is Ovie tickets, What is the unit price of each ticket I
all numbers are divisible by​
Which letter is NOT a Spanish letter? II ñ rr cc
What does Jem say caused the events leading up to it (When Jem broke his elbow) In To Kill a Mockingbird?
Simplify. 2( 5 3 + 3 4 ) − 4 3
In this excerpt from Walden by Henry David Leroux what can be inferred about where transcendentalist thinker searched for divinity? “Every morning was a cheerfu
Becker’s labeling theory best fits which sociological paradigm? Question 4 options: Structural functionalism social conflict symbolic interactionism pos
The function g is defined by g(x)=cx-3, where c is a constant. Find c if the value of g(x) at x=0.5 is equal to -1
PLEASE HELP ME!!!! I CANT DO THIS!!! WILL GIVE BRAINLIEST!!!! Divide 27x^3 − 72x^2 + 36x by 9x. A. 3x^2 − 8x + 4 B. 3x^2 + 8x − 4 C. 3x^3 − 8x + 4 D. 3x
Simplify the expression. 7x + 7 +5(x + 3) + 3