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

A racing car on a straight accelerates from 100mph to 316 mph in three seconds what is the acceleration?
។ What did John C. Calhoun support, which was in opposition to Jackson's view of government? A. Central Government B. Federal Authority C. State's Rights
Answer pleaseeeeeeeeeeeeeee pretty please
Marie-Ève et Denis font les courses. Complète leur conversation en utilisant les expressions de la boîte.
List the 3 things PLEASE ASAP
12÷3+(4×2)= 300×152÷(12×3)= 1988-1911= 2021-(16×2)=
Please help me #e484847572
What is true about market economies? A. People are free to start their own business. B. There is limited technology to advance products. C. People cannot start
Michelle and Juan are working on a science project. They take a large glass jar, fill it with some damp paper towels, and then with seeds. They place this jar n
GIVING BRAINLIEST AND THE REST OF MY POINTS!!!! :) What life cycle adaptation does the desert gold poppy have that helps it reproduce and survive in its dry des