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.
Related
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
So I understand Big-O, Big-Omega and Big-Theta conceptually, but I'm not sure how to prove Big-Omega and Big-Theta.
function f is in Big-O(g) if and only if there exists some constant c > 0 and some constant n_0 ≥ 1 such that for all n ≥ n_0, the expression f(n) ≤ c·g(n) is true.
Big-Omega is the opposite, c·g(n) ≤ f(n).
Big-Theta sandwiches c1·f(n) ≤ g(n) ≤ c2·f(n).
I need to prove/disprove if (2^{n})^{1/3} ∈ Θ(2^{n}) by using all three notations.
What I have so far:
Big-O : (2^{n})^{1/3} ≤ c·2^{n} when c=1 and n_0 = 1, so (2^{n})^{1/3} ∈ O(2^{n})
Big-Omega : We can rewrite (2^{n})^{1/3} = (1/(2^{2n/3}))·(2^n). We see that for c·g(n) ≤ f(n), c has to be ≤ 1/(2^{2n/3}) which is not possible since c > 0. So, there does not exist a c > 0 that satisfies c·g(n) ≤ f(n) and thus, (2^{n})^{1/3} ∉ Ω(2^{n})
Big-Theta : Since (2^{n})^{1/3} ∉ Ω(2^{n}), there is no lower bound c1·f(n) ≤ g(n). Therefore, (2^{n})^{1/3} ∉ Θ(2^{n})
Is this how you are supposed to prove it?
First simplify f(n) = (2^n)^(1/3) to f(n) = 2^(n/3). Then, take a limit of lim_{n\to\infty} f(n)/g(n) that g(n) = 2^n:
lim_{n\to\infty} 2^(n/3) / 2^n = lim_{n\to\infty} 1 / 2^(2n/3) = 0
Hence, f(n) = o(g(n)) (little-oh). It means f(n) is not in \Theta(g(n)). Notice that f(n) = O(g(n)) (Big-Oh) as it is in o(g(n)) (little-Oh).
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 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)).
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))