Comparing complexities - big-o

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))

Related

If f(n) = Θ(g(n)) does that f(n) is asymptotically equal to g(n)?

I'm fairly certain that if f(n) = Θ(g(n)) is true, if f(n) is asymptotically equal to g(n). However, I'm concerned I might be overlooking something. Am I correct in thinking that f(n) = Θ(g(n)) then f(n) is asymptotically equal to g(n)? or am I overlooking something?
I'm trying to compare different algorithms with respective runtimes of f(n) and g(n) and prove that f(n) = Θ(g(n)), but I'm not sure if I'm on the right way or not.
A. f(n) = log(n^100), g(n) = log(n^2)
lim n->∞ f(n)/g(n) = lim n->∞ log(n^200)/log(n^2) = 100
Since the result is a constant, we conclude that f(n) ∈ ϴ(g(n)), hence f(n) = ϴ(g(n)).
B. f(n) = sqrt(n), g(n) = log(n)
lim n->∞ f(n)/g(n) = lim n->∞ sqrt(n)/log(n) = ±∞, in my case ∞, hence f(n) ≠ ϴ(g(n)).
C. f(n) = 3^n, g(n) = 5^n
lim n->∞ f(n)/g(n) = lim n->∞ 3^n/5^n = 0, hence f(n) ≠ ϴ(g(n)).
D. f(n) = sin(n)+3, g(n) = cos(n)+1
lim n->∞ f(n)/g(n) = lim n->∞ sin(n)+3/cos(n)+1 = 4/3, hence f(n) ≠ ϴ(g(n)).
Please tell me, am I on the right way?
Am I correct in thinking that if f(n) = Θ(g(n)) then f(n) is asymptotically equal to g(n)?
No, asymptotic equality is a stronger claim than asymptotically bound. The opposite is true: when 𝑓(𝑛) is asymptotically equal to 𝑔(𝑛), then 𝑓(𝑛) is Θ(𝑔(𝑛))
As defined on Wikipedia - Asymptotic Analysis:
if and only if
𝑓(𝑛)
lim ──── = 1
𝑥→∞ 𝑔(𝑥)
the functions 𝑓 and 𝑔 are said to be asymptotically equivalent.
For the first example where 𝑓(𝑛) = log𝑛¹⁰⁰ and 𝑔(𝑛) = log𝑛², this equivalence does not hold:
log𝑛¹⁰⁰ / log𝑛² = log𝑛¹⁰⁰ − log𝑛² = log𝑛⁹⁸, whose limit diverges to infinity and so 𝑓(𝑛) and 𝑔(𝑛) are not asymptotically equal.
See also Wikipedia - Family of Bachmann–Landau notations

How to operate on Asymptotic Notation Function Sets ie. Big-O + Big-Omega?

I'm trying to determine if the following statement is true or false.
If f(n) ∈ O(n) and g(n) ∈ Ω(n), then f(n) + g(n) ∈ Θ(n).
I think I understand adding the same asymptotic big-O. O(n) + O(n) = O(n)
However, I am unsure about adding or operating on the others combined.
For example:
If f(n) ∈ Θ(n log n), then f(n) * n = ?
Could this answer be both O(n^2*logn) and Θ(n^2*logn)?
Thank you in advance!
You can use the definition of these symbols and try to find a proof or a contradiction example for them.
If f(n) = O(n) and g(n) = Omega(n), the f(n) + g(n) is not in Theta(n) necessarily! As a contradiction, if f(n) = n and g(n) = n^2, then f(n) + g(n) = Theta(n^2). On the other hand, if f(n) = n and g(n) = n, then f(n) + g(n) = Theta(n). Hence, you can just say f(n) + g(n) = Omega(n) and nothing more.

Asymptotic notation properties proofs?

I am trying to prove that if f(n) and g(n) are asymptotically positive functions, then:
f(n) = O((f(n))^2)
f(n) = O(g(n)) implies 2^(f(n)) = O(2^(g(n)))
f(n) = O(g(n)) implies g(n) = O(f(n))
1) Theorem: If f(n) is an asymptotically positive function from natural numbers to natural numbers, then f(n) = O((f(n))^2) (note I have added an extra, perhaps implied, assumption).
Proof: Because f(n) is an asymptotically positive function from natural numbers to natural numbers, it is guaranteed that for all natural numbers n greater than or equal to some natural number n0, f(n) > 0, hence f(n) >= 1. Because f(n) is guaranteed to be positive we are free to multiply both sides of the inequality by f(n) without changing the direction to get f(n)^2 >= f(n). Therefore, we can choose c = 1 and use the n0 from the assumption to show that f(n) = O((f(n))^2). (Recall that by the definition of Big-Oh, f(n) = O(g(n)) if and only if there exist constants c > 0, n0 such that for n >= n0, f(n) <= c * g(n)).
2) Theorem: if f(n) and g(n) are asymptotically positive functions from natural numbers to natural numbers and f(n) = O(g(n)), then it is not necessarily true that 2^(f(n)) = O(2^(g(n)).
Proof: The proof is by example. It can be shown that 4n = O(2n). 4n and 2n are both asymptotically positive functions from naturals to naturals. However, it can also be shown that 2^(4n) = 16^n is not O(2^(2n)) = O(4^n).
3) Theorem: if f(n) and g(n) are asymptotically positive functions from natural numbers to natural numbers and f(n) = O(g(n)), then it is not necessarily true that g(n) = O(f(n)).
Proof: The proof is by example. It can be shown that n = O(n^2). n and n^2 are both asymptotically positive functions from naturals to naturals. However, it can also be shown that n^2 is not O(n).
f(n) = O((f(n))2)
Any function is by default big-O of itself, i.e. we can use a bigger constant cbig such that f(n) <= cbig.f(n).
Thus,
if f(n) is less than or equal to cbig.f(n),
then f(n) will definitely be less than or equal to cbig.f(n).f(n), for asymptotically positive f(n).
Mathematically, f(n) = O(f(n).f(n)) = O(f(n)2) is true.
f(n) = O(g(n)) implies 2f(n) = O(2g(n))
f(n) = O(g(n)) implies that f(n) <= g(n)
Also, if some positive number n is less than m, then 2n will be less than 2m
Using 1. and 2. above, we can conclude that if f(n) = O(g(n)), then 2f(n) = O(2g(n))
f(n) = O(g(n)) implies g(n) = O(f(n))
This one is wrong.
f(n) = O(g(n)) implies g(n) = Ω(f(n)).
If f(n) = O(g(n)), then f(n) is upper bound by g(n) which means that g(n) is lower bound by f(n), therefore g(n) = Ω(f(n)).

Big O notation constants

Given the following functions f(n) and g(n), is f in O(g(n)) or is f in Θ(g(n)),
or both? If true, specify a constant c and point n0, if false, briefly specify why.
(a) f(n) = 2n , g(n) = 2^2n
(b) f(n) = n!, g(n) = 2n
I do understand for (a), f(n) = O(g(n)) because g(n) upper bounds f(n)
and for (b), g(n) = O(f(n)) because of dominance relativity on the fact that n! > 2^n..
I have done some research but could not find much on how to calculate the constants c and n0 for this type of questions. thanks for the reply :)
a) f(n) = 2n , g(n) = 2^(2n)
(I added parenthesis.)
f(n) = O(g(n)) iff | f(n) | <= C * | g(n) | for some C>0 and all n > n0
2n <= 1*(2^(2n)) for n>1
Therefore 2n = O(2^(2n)). My constants are C=1 and n0 = 1. But others work too.

What is the highest possible big O complexity?

Curious O(n^n) is pretty high but O(n^n^n) is higher and O(n^n^n^n) is higher still. Is there a highest big O?
Suppose there exists a maximal big O complexity given by f, that is,
g(n) ∈ O(f(n)), ∀ g:ℝ->ℝ
Then, let g(n) = f(n)^2.
Since lim f(n) = ∞,
f(n) f(n) 1
lim ──── = ────── = ──── = 0
g(n) f(n)^2 f(n)
That means g(n) ∉ O(f(n)). Contradiction.

Resources