Is the following equation true? :
O(f(n)) + Ω(g(n)) = Ω(f(n)) + O(g(n))
I know that Big O means no better than (function), and Big Omega means no worse than (function). But I don't know if that makes the above statement true or false.
We have three general cases (for increasing functions):
Case 1: f(n) ∈ o(g(n)) (note the "little-oh").
In this case, O(f(n)) ⊂ O(g(n)) and Ω(g(n)) ⊂ Ω(f(n)). Hence, O(f(n)) + Ω(g(n)) is a proper subset of O(g(n)) + Ω(f(n)).
For example, if f(n) = n and g(n) = n3, then n2 is in Ω(f(n)) + O(g(n)), but it is not in O(f(n)) + Ω(g(n)).
Case 2: f(n) ∈ Θ(g(n))
In this case, O(f(n)) = O(g(n)) and Ω(g(n)) = Ω(g(n)), so the two sets are equal.
Case 3: f(n) ∈ ω(g(n))
This case is equivalent to case 1, just with f and g flipped. So by symmetry, we have that O(f(n)) + Ω(g(n)) is a proper superset of O(g(n)) + Ω(f(n)).
In sum, these two sets are not equal in general.
Let $f(n) = n, g(n)= 2^n$
$t(n) = 2n$ is in second set, because $n = Ω(f(n))$ and $n = O(g(n))$, but not in the first
Related
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.
I came across this statement, as per my understanding Theta lies between Big O and Omega but I am unable to understand why intersection comes here. Can I get a mathematical as well as analytical understanding for Θ(g(n)) = O(g(n)) ∩ Ω(g(n))
Θ(g(n)) means that the function is bound both above and below by g(n).
Mathematically, if a function f(n) is Θ(g(n)), then
0 ≤ c1.g(n) ≤ f(n) ≤ c2.g(n) for all n greater than some constant k
Now,
O(g(n)) is upper bound on g(n), so a function that is O(g(n)) is upper bounded by g(n).
Ω(g(n)) is lower bound on g(n), so a function that's Ω(g(n)) is lower bound by g(n).
O(g(n)) ∩ Ω(g(n)) is representative of a function sandwiched between g(n) from both above and below, as shown in the image below, which by definition would be Θ(g(n)).
Mathematically, that means the function is 0 ≤ c1.g(n) ≤ f(n) ≤ c2.g(n).
If f(n) is O(g(n)) but not o(g(n)), is it true that f(n) is theta(g(n))?
Similarly, f(n) is Omega(g(n)) but not omega(g(n)) implies f(n) is theta(g(n)).
If not, can you provide an explanation/counter-example please?
*NOTE : think of O as <= and o as <.
If f(n) is O(g(n)) but not o(g(n)), is it true that f(n) is
theta(g(n))?
Yes, f(n) ∈ Θ(g(n)).
f(n) = O(g(n)) means f(n) ≤ Cg(n).
f(n) = o(g(n)) is possible if and only if f(n) = O(g(n)), but f(n) ≠ Θ(g(n)).
So, since f(n) is not o(g(n)), but it is O(g(n)), hence, f(n) ∈ Θ(g(n)).
*NOTE : think of Ω as >= and ω as >.
Similarly, f(n) is Omega(g(n)) but not omega(g(n)) implies f(n) is
theta(g(n)).
Yes, f(n) ∈ Θ(g(n)). Following the similar logic :
f(n) = Ω(g(n)) means f(n) ≥ cg(n).
f(n) = ω(g(n)) is possible if and only if f(n) = Ω(g(n)), but f(n) ≠ Θ(g(n)).
So, since f(n) is not ω(g(n)), but it is Ω(g(n)), hence, f(n) ∈ Θ(g(n)).
I have these three questions for an exam review:
If f(n) = 2n - 3 give two different functions g(n) and h(n) (so g(n) doesn't equal h(n)) such that f(n) = O(g(n)) and f(n) = O(h(n))
Now do the same again with functions g'(n) and h'(n), but this time the function should be of the form
g'(n) = Ɵ(f(n)) and f(n) = o(h'(n))
Is it possible for a function f(n) = O(g(n)) and f(n) = Ω(g(n))?
I know that a function is O(n) of another, if it is less than or equal to the other function. So I think 1. could be g(n) = 2n²-3 and h(n) = 2n²-10.
I also know that a function is Ɵ(n) of another if it is basically equal to the other function (we can ignore constants), and o(n) if it is only less than the function, so for 2. I think you could have g'(n) = 2n-15 and h'(n) = 2n.
To 3.: It is possible for a function to be both O(n) and Ω(n) because O(n) and Ω(n) allows for the function to be the same as the given function, so you could have a function g(n) that equals f(n) and satisfies the rules for being both O and Ω.
Can someone please tell me if this is correct?
Your answers are mostly right. But I would like to add some points:
Given is f(n) = 2n - 3
With g(n) = 2n²-3 and h(n) = 2n²-10 f(n) is in O(g(n)) and in O(h(n)). But your g(n) and h(n) are basicly the same, at least they are both in Θ(n²). There exists many other function that would also work. E.g.
f(n) ∈ O(n) ⇒ g(n) = n
f(n) ∈ O(nk) ⇒ g(n) = nk ∀ k ≥ 1
f(n) ∈ O(2ⁿ) ⇒ g(n) = 2ⁿ
g'(n) = 2n-15 reduces to g'(n) = n, if we think in complexities, and this is right. In fact, it is the only possible answer.
But f(n) ∈ o(h'(n)) does not hold for h'(n) = 2n. Little-o means that
limn → ∞ | f(n)/g(n) | = 0 ⇔ f(n) ∈ o(g(n))
So you can choose h'(n) = n² or more general h'(n) = nk ∀ k > 1 or h'(n) = cⁿ for a constant c > 1.
Yes it is possible and you can take it also as a definition for Θ(g(n)):
f(n) ∈ Θ(g(n)) ⇔ f(n) ∈ O(g(n)) and f(n) ∈ Ω(g(n))
I have a small query.
Can f(n) belong to both o(g(n)) and big omega(g(n))?
I'm not able to figure it out. Can someone explain me please?
No it can't. Since o(g(n)) means time complexity strictly less than g(n) and ω(g(n)) strictly greater.
New answer (for editted question):
No, it cannot.
Formal proof, based on set theory and the fact that o(g(n)) and Ω(g(n)) are sets of functions:
o(g(n)) = O(g(n)) \ Θ(g(n))
Θ(g(n)) = Ω(g(n)) ∩ O(g(n))
o(g(n)) ∩ Ω(g(n)) = { O(g(n)) \ Θ(g(n)) } ∩ Ω(g(n))
= { O(g(n)) ∩ Ω(g(n)) } \ Θ(g(n)) [see appendix 1]
= Θ(g(n)) \ Θ(g(n)) = {}
Since o(g(n)) ∩ Ω(g(n)) is an empty set, there is no function f(n) that belongs to the intersection, thus no function belongs to both sets.
QED
Appendix 1:
Let's make sure we understand this equality:
(1) = { O(g(n)) \ Θ(g(n)) } ∩ Ω(g(n)) = { O(g(n)) ∩ Ω(g(n)) } \
Θ(g(n)) = (2)
If x is not in O(g(n)) - it is not in (1), and also not in (2),
regardless of appearing in the other sets.
if x is in O(g(n)) and in Θ(g(n)), it is not in (1) and also not in
(2), regardless of appearing in Ω(g(n))
if x is in O(g(n)), not in Θ(g(n)) and yes in Ω(g(n)), it is both in (1) and in (2)
if x is in O(g(n)), not in Θ(g(n)) and not in Ω(g(n)), it is not in (1) and also not in (2)
Since this concludes all possibilities, and we found that in all of them, x is in (1) if and only if it is also in (2), the equation is true.
Old answer (for original question, asking about small omega):
No, it cannot.
Formal proof, based on set theory and the fact that o(g(n)) and ω(g(n)) are sets of functions:
o(g(n)) = O(g(n)) \ Θ(g(n))
omega(g(n)) = Ω(g(n)) \ Θ(g(n))
o(g(n)) ∩ ω(g(n)) = { O(g(n)) \ Θ(g(n)) } ∩ { Ω(g(n)) \ Θ(g(n)) }
= { Ω(g(n)) ∩ O(g(n)) } \ Θ(g(n))
= Θ(g(n)) \ Θ(g(n))
= {}
Since o(g(n)) ∩ ω(g(n)) is an empty set, there is no function f(n) that belongs to the intersection, thus no function belongs to both sets.
QED
We can use the definitions of o(n) and Omega(n):
We assume that there is a function g with the following properties: g(n) = o(f(n)) and g(n) = Omega(f(n)).
If g(n) = o(f(n)) then for every positive constant c1: 0 <= g(n) < c1 * f(n). (1)
If g(n) = Omega(f(n)) then there is a positive constant c2 for which 0 <= c2 * f(n) <= g(n).
Statement (1) is also true for c1 = c2, which means that
0 <= g(n) < c2 * f(n) and 0 <= c2 * f(n) <= g(n).
Now we have g(n) < c2 * f(n) and g(n) >= c2 * f(n), which is impossible, so our initial assumption is false. So, there is no such function g, and the intersection of o(f(n)) and Omega(f(n)) is the empty set.