Find a simple function gn whose exponents are as small as po

Find a simple function g(n) whose exponents are as small as possible, for which the following code runs in time O(g(n)).

Solution

The for i loop will run from i equal to n to 3^n, hence the Order for that loop is equal to 0(3^n)

The inner loop whiie run will be false when

6j < n^3

it will run at max log(n^3) to the base 6 times

Hence the max value of the function will O(3^n * log(n^3) to the base 6)

 Find a simple function g(n) whose exponents are as small as possible, for which the following code runs in time O(g(n)). SolutionThe for i loop will run from i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site