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 65-inch HD LCD television is discounted 25% from the original price. If the discounted price is $1799.99, what was the original price of the television?
Fallon is afraid of loud sounds, like thunder. She associates lightning with thunder because it regularly precedes thunder. Thus, when Fallon sees lightning, sh
What is 4,-5 reflected across the x axis
An unknown liquid has a mass of 30.8 g, and a volume of 31.5 mL. What is the density of this liquid?
what are your thoughts on age discrimination
Find the value of each variable.
What's the answer for 4 and 5 I'm really confused. Help please. Also number 5 you select multiple answers.
Based on your​ reading, information systems help businesses compete​ ________.
Which segment of the hospitality industry includes theme parks zoos and beaches
Can i use some help? im really confused on how to show my work and all