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 user is concerned about losing critical data on single computer in the event of an unforeseen system crash. The user is advised to implement fault tolerance.
Find a formula for the inverse of the following function, if possible. r(x)=(x^3−5)^1/3+2 r^-1(x)=? Or it dose not have an inverse function
The value of a machine, V, at the end of t years is given by V=C(1−r)t , where C is the original cost and r is the rate of depreciation. Find the value of a mac
is our calendar today based of the mayan calendar
The difference of a number p and 7 is 13?
3/11 of what number is 12
Simply 3m/9m^2-1 -1/2(3m+1)
Please help this is for math
Which use of the Internet could have a negative impact on a company's competitive position?
Given the sample space, S={1,2,5,6,9}. What is the total number of possible events?