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

what's another word for over thinking?
you have a standard deck of 52 cards. you pick one card and then, with out putting the first card back, you pick a second card. what is the probability that bot
what is a high structure part of a church which has 5 letters
what is a high structure part of a church which has 5 letters
Mini-Project: Cents and the Central Limit Theorem 1. Collect a sample of at least 50 pennies by setting aside all the pennies you receive in change for severa
Mini-Project: Cents and the Central Limit Theorem 1. Collect a sample of at least 50 pennies by setting aside all the pennies you receive in change for severa
how do you write 4540 million in standard form?
How do you?...Multiply out and simplify 10(2x-1)-20x?
What is the amplitude of y=1/2 sin2x
you have a standard deck of 52 cards. you pick one card and then, with out putting the first card back, you pick a second card. what is the probability that bot