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

Fact or option Fourth of July is celebrated in July.
plz prove this for me.....sin^6 (x)+ cos^6 (x)=1- 3/4 sin^2 (2x)I'll reward u guyz with many pts plus brainliest ​i need full steps
Please answer the attached question by selecting of the the given answers.
Please answer the attached question by selecting of the the given answers.
The last battle of the war was fought at — ? Fighting The Revolutionary War
If you change your name or address, you should report it to the DPS to receive a new license within __________ . A. 30 days B. 60 days C. 90 days
Which of the following is an accurate description of a Type I: Offshore Life Jacket (PFD)? It is designed for calm, inland waters It is designed for open, rou
Is this positive or negative
find the area and perimeter of the shaded part.
You are a scientist working on increasing the efficiency of appliances to waste less electricity. You are running experiments measuring the input, output, and w