5 Determine the asymptotic running time for the following pi

5- Determine the asymptotic running time for the following piece of code, assuming that n represents the input size.

Solution

Answer:

d) In the given code , there are two for loops . One is running from 0 to n -----> O(n)

Other is running 0 to i , i is running from 0 to n , therefore ----> O(n)

Total = O(n) * O(n) = O(n^2)

e)

In this piece of code , there are 3 loops

Therefore total runnig time = O(n) * O(n^2) * O(n^2) = O(n^4)

f) Here are two loops:

Total = O(log^n)

 5- Determine the asymptotic running time for the following piece of code, assuming that n represents the input size. SolutionAnswer: d) In the given code , the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site