Prove that |O(2n)-O(n)|=O(n)

73 Views Asked by At

I need to prove that statement with the defenition of big O

    |O(2n)-O(n)|=O(n)

Does it can be proven? or not?

if i can, so how..in which way? i tried almost everything

1

There are 1 best solutions below

1
On

By definition, $O(2n) = O(n)$, as constants are dropped with asymptotics. Remember that $f(n) = O(g(n))$ if and only if $|f(n)| \leq C * |g(n)|$, for a constant $C$ and $n \geq n_{0}$. So trivially, $n = O(2n) = O(n)$. It's also easy to see that $f(n) = O(f(n))$.

So let $f(n) \in O(2n)$ and $g(n) \in O(n)$. So $f(n) \leq 2Cn$ and $g(n) \leq Kn$. Subtracting them, you get $(2C-k)n$. That's clearly $O(n)$.