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 is biogeography and what does it provide?
which seismic wave moves through earth at the fastest speed?
the cafeteria has 45 square  tables that can be pushed together to form one long table for the lacrosse team's banquet. Each square table can seat one person on
Find all powers of 4 in range 4 through 1,000
Which of the following can be considered fossils? a. a 1 billion year-old rock. b. a 1 billion year-old piece of amber. c. a 1 billion year-old piece of amber w
By the mid-1700s, the largest city in the colonies was (A) New York (B) Boston (C) Philadelphia (D) Charleston (E) Wilmington, Delaware
Find all powers of 4 in range 4 through 1,000
5x+4y+100 in slope intercept form
The height of a rectangular prism with a 20 cm by 12 cm base and a 30 cm diagonal.find the unknown dimension
If a slope of a line is 2/0 is it 0 or undefined?