Trouble with nested loop

84 Views Asked by At

With the definition of Big-Oh, I'm required to prove $\log_b(g(n))$ is big-oh of $\log_b(f(n))$. I may assume $g(n)$ is big-oh of $f(n)$, $f(n)$ and $g(n)$ are eventually $\geq b$ and $b > 1$.

However, I'm stuck and I don't know where to being or what to do even. Any hints towards proving $\log_b(g(n))$ is big-oh of $\log_b(f(n))$?

BTW, $\log_b$ means $\log$ base $b$. Any help is greatly appreciated. Thank you.

def nested(n):

"""Assume n is an integer and n > 1."""

b = 1

while b <= n:

    i = 1

    while i < b:
        print(i)
        i = i*3
    b = b + 1
1

There are 1 best solutions below

6
On

Since b>1 you can pull out the base b with log properties.
logb(a) = log(a) / log(b) and then you end up trying to show that log(g(n)) is O(log(f(n)))
You can do this since b>1 and so log(b) > 0.

Not sure if that helps :P
(I don't know how to make b a subscript, so by logb I meant log with base b.)