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

Your paper must be your own ___ product
How many electrons are transferred in the iconic bond between sodium abd chlorine in naci?
Identify two examples of irony in 'Toy Story of Terror' and explain how each of these examples is ironic.
What substance is used in the industrial preparation of methyl diantilis to reduce the aldehyde group of 3-ethoxy-4-hydroxybenzaldehyde?
"what kinds of birds visit a feeder at different times of the years"
how to solve two-step equations with fractions
Chloe enjoys her math classes and she would like to find a career that will allow her to continue to use her math skills which career would be a good fit for he
Which word from the life cycle of perennials glossary defines the part of a bulb that reserves food?a- rhizome B- scale C-basal plate D- corm
What does ph measure? 6. msg behaves as a buffer. what is a buffer? 7. if we are interested in understanding how msg behaves as a buffer, what is the rationale
how to solve this question.