128k views
5 votes
In the following code segment, if the algorithm doIt has an efficiency factor of 5n, calculate the run-time efficiency of the program and determine its big-O notation, (4pts) for (int i=1; i<=n; i++) doIt(…)

1 Answer

3 votes

Answer:

run-time efficiency = 5n²

big-O notation = O(n^2)

Step-by-step explanation:

for (int i=1; i<=n; i++)

doIt(…)

solution :

doIt = 5n

doIT() is dependent on n itself, then calling it within a loop also dependent on n , that makes 5n²

and

T(n) ∈ O(n^2)

In the following code segment, if the algorithm doIt has an efficiency factor of 5n-example-1
User Nidhin
by
5.2k points