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

How do you block someone? BE SPECIFIC.
Which dot plot has more than one mode
Cedric's basketball team scored fewer than 76 points in their last game. Which of the following inequalities represents the number of points Cedric's basketball
Which of the following are true of the Ferderalist papers?
An expression Is shown: 88÷13 between which two consecutive whole numbers does this value lie
Each marble bad sold by Diane's Marble Company contains 4 yellow marbles for every 5 blue marbles. If a bag has 30 blue marbles, how many yellow marbles does it
i need to find the surface area of the cube
Are both of these answers correct? Thank you to anyone who answers, it really helps me
Equation Help For Thank You​
what is the median of 10 36 6 23 30 4 12 22 19 21 39 5