Finding if f(n) = O(g(n) and vice versa...

142 Views Asked by At

Define $f(n) = \{ 3n-1$ if n is divisible by 3.. $n^2$ otherwise

and $g(n) = \{ n^2$ if n is divisble by 3.. $2n$ otherwise

Is $f(n) = O(g(n))$, is $g(n) = O(f(n))$?

Here is my attempt at solving this problem:

$f(n) = 3n -1 = O(n)$

$g(n) = n^2 = O(n^2)$

$\therefore f(n) = O(g(n))$ but $(g)n \ne O(f(n))$

Then I let

$f(n) = n^2 = O(n^2)$

$g(n) = 2n = O(n)$

$\therefore f(n) \ne O(g(n))$ but $g(n) = O(f(n))$

This problem is set up so damn weird. Am I even doing the right thing? It's almost like it has different functions so I'm just assuming to match the functions when they have similar rules? I'm not really sure. By the way, my professor said "This problem cannot be expressed as Big O Notation".. But he didn't really give us any kind of solution so i'm very confused how to solve this.