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

If no fixed duration of the partnership is specified, the partnership is a partnership in perpetuity, which means that the partnership cannot be dissolved. a.
whats 6.09 billion in scientific notation?
What is Friar Laurence saying? [T]he sweetest honey Is loathsome in his own deliciousness And in the taste confounds the appetite: (II. vi. 13-15) Sugary thin
Can anyone help ME? PLEASE HELP IF I DONT TURN THIS IN BY TOMMOROW I DONT GET TO GO TO NEW YORK AND THAT IS MY DREAM
Yo por la mañana. (ducharse)
The elements with the highest ionization energy, and thus the lowest reactivity are
arched roof that connects walls and creates more open space in a structure
What is the GCF 135, 189 , 297
The fluid mosaic model describes the___. A.organization of organelles in cytoplasm B.cell membrane C.movement of carbohydrates in and out of the cell D.extrac
Which of the 5 pillars of Islam refers to giving to poor and needy