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

Mrs. Ruiz bought 5 bags of balloons for a party. Each bag contained 70 gallons. Andy said Mrs. Ruiz bought a total of 75 gallons. Andy is incorrect. What err
plz help i need this done
jurisdiction means the
1. What do the words “good night” denote in these lines from Dylan Thomas' poem, "Do Not Go Gentle into that Good Night"?
____________ is the accumulation of information, skills, and strategies that people have learned through experience and that they can apply in problem-solving s
help please help please
During the propagation of the excitation wave along the sarcolemma, the action potentials travel down the
The senate watergate committee was an example of answers
The title for a West African storyteller and living archive is
What is the history on people with Tuberculosis??