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

All the factors of 80
is -21 perpendicular to 3
Solve for v P=2/3(N/V)1/2mv2
Which of the following is a protic solvent? Q3.5: CHзон A (CH3)3N NF3 C
What percent of 4,000 is 64
Given: m∠QVR = 49° Prove: x = 15 Complete the steps of the proof. ♣: ♦:
Select the correct answer. What is the purpose of a literary analysis essay? A. to dissect a literary work to determine its meaning B. to summarize a literary
To find force you multiply mass by accelerations; if I have a 5.0 gram Matchbox car accelerating at 7.0 m/sec2 How many Newtons (N) of force will it hit the wal
What would you be willing to work hard to achieve if you knew it was possible?
Which of the following are solutions to the equation below? Check all that apply. (5x - 2)2 = 10