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 music-streaming service charges $9 per month for a single user. Additional users within the same household can be added for $3 per month. Write an equation th
I’m really stuck please can someone help
When writing your speech, it is important to use _______ language.
what is the answer to the question?
Please answer all 5 xoxo <3
How much percent of shops are in the city? How about in the country? HELP PLS WILL GIVE BRAINLY FAST
Question 1 1.1. Do a research on three challenges faced by any business around your area. (3) 1.1.2 Classify the challenges according to the three business envi
A housewife used excessive amount of sodium nitrate and phosphate fertiliser to her tree, after 3 days, she found her tree had withered and died.
what is the full form of LAN​
Given the following specific heat capacities, which material was have the largest change in temperature if 10 grams of each substance absorbs 100 calories of he