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 know not what course others may take; but as for me, give me liberty or give me death!—Patrick Henry How did Patrick Henry act on this idea? He became a membe
Order of events within a scene. a. Foreshadowing b. Flashback c. Alliteration d. Allegory
The cotton gin and the sewing machine both contributed to the growth of which industry?
What is the adjective clause in the sentence? Janelle, whom the puppy loves to lick, is getting plenty of puppy kisses all over. A. of puppy kisses B. is get
how did the loyalists and patriots differ on the issue of independence for the colonies?
178 rounded to the nearest hundred
How does the process of waste removal in a unicellular compare to waste removal in a multicellular organism?
What is 4 4/9 times 2 2/3
What is 7/8 and 4/9 closer to 0,1,2,or 3
Write a division problem that has a 3 digit dividend and a divisor between 10 and 20