Prove f(n) + g(n) is O(max(f(n),g(n))) - algorithm

Hello I am having a bit of difficulty proving the following.
f(n) + g(n) is O(max(f(n),g(n)))
This makes logical sense, and by looking at this I can tell you that its correct but I'm having trouble coming up with a proof.
Here is what I have so far:
c * (max(f(n),g(n))) > f(n) + g(n) for n > N
But I'm not sure how to pick a c and N to fit the definition because I don't know what f(n) and g(n) are.
Any help is appreciated.

f(n) + g(n) <= 2* max{f(n),g(n)}
(for each n>0, assume f(n),g(n) are none-negative functions)
Thus, for N=1, for all n>N: f(n) + g(n) <= 2*max{f(n),g(n)}, and we can say by definition of big O that f(n) + g(n) is in O(max{f(n),g(n)})
So basically, we use N=1, c=2 for the formal proof by definition.

Related

Proof of f(n) + ο(f(n)) = Θ(f(n))

Can you please help me prove this? I am trying to set o(f(n))= g(n) and then try to solve the equation
f(n) + g(n) = Θ(f(n)) but I don't know if it is the correct way, and if it is I don't know how to continue my solution. Thank you
Assuming that all the functions are non-negative (otherwise you need to adjust the below proof and definitions to cope with signs).
Suppose g(n) = o(f(n)). That means that for all c>0, there's an N such that n>N implies g(n) < cf(n). So in particular, there's an N such that n>N implies g(n) < f(n) (ie: pick c=1 in the definition).
We also have from the assumption that the functions are non-negative that f(n) <= f(n) + g(n).
Then we have for n>N, f(n) <= f(n) + g(n) < 2f(n) for all n>N. Thus f(n) + g(n) = Theta(f(n)).

Asymptotic Growth: Understanding the specific proof of f(n) + little o(f(n)) = theta (f(n))?

I'm working through proof of f(n) + o(f(n)) = theta (f(n)) and I came across a part in the proof that I am having trouble understanding.
We let f(n) and g(n) be asymptotically positive functions and assume g(n) = O(f(n)).
In the proof, it states that since we know that f(n) + g(n) ≥ f(n) for all n, we can conclude that f(n) + g(n) = Omega((f(n)).
We can also conclude similarly that f(n) + g(n) ≤ 2 f(n). Therefore f(n) + g(n) = O(f(n)).
I am having trouble understanding why it is the case that f(n) + g(n) = Omega((f(n)) and f(n) + g(n) = O(f(n)) would be true. How is it that we can prove that the tight-lower bound is specifically when we add g(n) to f(n)? What is it that we are exactly concluding from the value of g(n)?
One way of proving that f(n) is theta(g(n)) is to prove two separate statements: that f(n) is omega(g(n)), and f(n) is O(g(n)). It's pretty clear this way of proving is correct from the definitions of those notations.
In this exact problem, if we choose some constant c to be equal to 1, we will have, for every n, that f(n) + g(n) >= c * f(n), so that, by definition, shows that f(n) + g(n) is Omega(f(n)). Furthermore, for the O(f(n)) part, if we choose the constant c to be 2 in this case, we need to prove that there exists some n0 such that f(n) + g(n) <= c * f(n) for every n > n0, which is equivalent to g(n) <= f(n) for every n > n0, which is equivalent to the definition of g(n) = O(f(n)) given in the problem statement.
Hope this helps.

To prove or disprove the given Asymptotic notations

Prove or Disprove
1) max{ f(n), g(n)} = O(f(n) + g(n)), where f(n) and g(n) are positive functions.2) min{ f(n) , g(n)} = Ω(f(n) + g(n)), where f(n) and g(n) are positive functions.
My proof for the first question is something like, max {f(n) + g(n)} would be > than f(n) + g(n). So setting the constant c to the max {f(n) + g(n)} will make the Big'O condition hold true. Is this the right way to go about doing it? Also, I'm not sure as to how to go on to prove the secon question, so any help with regard to that would be much appreciated.
The first one is correct. As max(f(n),g(n)) < f(n) + g(n). The second one is incorrect. You can show that by contrdition. Suppose f(n) = log(n) and g(n) = n. We can see that min(f(n),g(n)) = log(n) but we know that log(n) is not Omgea(n + log(n)).

How to prove the complexity of a logarithmic function?

Let's say you were given two logarithmic functions like
and you were asked to find if f(n) is O(g(n)) Ω(g(n)) or Θ(g(n)), how would you go about it? I found questions like these easier when you were comparing two exponential equations, because for example with x(n) = n^2 and p(n) = n^2 you could find a c > 0 (ex 3) where x(n) <= cp(n) for all n greater than some n>0 and that would prove that x(n) = O(p(n)). However, comparing two logarithmic functions seems much more difficult for some reason. Any help is appreciated, thanks!
f(n) is O(g(n)) iff there is a constant c and n_0 such that f(n) <= c * g(n) for each n >= n_0.
f(n) is Ω(g(n)) iff there is a constant c and n_0 such that f(n) >= c * g(n) for each n >= n_0.
Now, f(n) is Θ(g(n)) iff f(n) is O(g(n)) and f(n) is Ω(g(n)).
So, in your cases, we have:
f(n) = log (n^2) = 2logn
which means, g(n) is logn and c = 2, which means f(n) <= 2 * logn and f(n) >= 2 * logn, which makes it Ω(logn).
Btw. its also f(n) <= n and f(n) >= 1, so f(n) can be O(n), but we don't use it, since we can find a better O(g(n)). In this case we don't have the same function in both notations, to for those values we don't have Ω. However, we just need one option for g(n) to declare Ω. In cases we can't find it, we say its not Ω. Note the word "we say".
In second case, we care only for "highest growing value", logn part. Now, c = 1, and g = log(n), so in this case, its also Ω(logn).

Showing f(n) = O(f(n) + g(n))?

I was wondering what the proof for the following Big-O comparison is:
f(n) is O(f(n) + g(n)))
I understand that we could use:
f(n) ≤ constant * (f(n) + g(n))
But I don't know how to follow up.
What about the case where we replace big-O with big-Ω?
If you know that the function g(n) is nonnegative, then note that
f(n) ≤ f(n) + g(n) = 1 · (f(n) + g(n))
Given this, could you use the formal definition of big-O notation to show that f(n) = O(f(n) + g(n))?
If g(n) isn't necessarily nonnegative, then this result isn't necessarily true. For example, take f(n) = n and g(n) = -n. Then f(n) + g(n) = 0, and it's not true that f(n) = O(0).
As for the Ω case, are you sure this result is necessarily true? As a hint, try picking f(n) = n and g(n) = 2n. Is f(n) really Ω(f(n) + g(n)) here?
Hope this helps!

Resources