Given f(n) = n^[(1+sin(n*pi/2))/2] and g(n) = n^0.5
, how do I prove that f(n) = O(g(n)) / f(n) = Omega(g(n)) / f(n) = Theta(g(n)).
I have worked out that f(n) doesn't seem to have a bound as the function grows bigger and smaller as n grows big.... (i plotted the graph here)
https://www.desmos.com/calculator/xtrh124rjb
So How would one justify which does it belong to ?
Or does it belong to neither of them since it doesn't have a bound at all....?
Consider the sequence 1, 5, 9, …, 4k + 1, … For these values of n, (1 + sin(n * pi / 2)) / 2 = 1. Therefore, for these values of n, your function is identical to the function A(n) = n^1 = n. Note that A(n) = n is NOT O(g(n)) = O(n^0.5); n grows asymptotically faster than n^0.5.
Consider the sequence 3, 7, 11, …, 4k + 3, … For these values of n, (1 + sin(n * pi / 2)) / 2 = 0. Therefore, for these values of n, your function is identical to the function B(N) = n^0 = 1. Note that B(n) = 1 is NOT Omega(g(n)) = Omega(n^0.5); n^0.5 grows asymptotically faster than the constant 1 (which doesn't grow at all).
Either f(n) not being O(g(n)) OR f(n) not being Omega(g(n)) would have already disqualified f(n) from being Theta(g(n)).
Note: f(n) = O(A(n)) and f(n) = O(B(n)). f(n) = Theta(h(n)) where h(n) is any function which oscillates like f(n) and which grows at least as fast and which has a constant lower bound.
Related
I was reading an article and came across the following :
Informally, O(g(n)) can be defined as the set of mathematical functions that contains all functions that don’t “grow faster” than g(n). Thus, all functions below are in the set O(n²):
f(n) = n²+3n + 2, f(n) = n log(n), f(n) = 3n+1
.
Can please anyone tell me how f(n) = n²+3n + 2 grows faster than g(n)?
Can please anyone tell me how f(n) = n²+3n + 2 grows faster than g(n)?
Here is one way to understand it (a bit informal, but I find it more intuitive).
Let L be limit as n goes to infinity of f(n)/g(n)
If L is infinity then f(n) grows faster than g(n) (numerator overwhelms denominator).
If L is 0 then f(n) grows slower than g(n) (denominator overwhelms numerator)
If L is finite number then they have same (comparable) growth rates.
We can define O(g(n)) as the following set:
O(g(n)) = { f(n) ∶ ∃ c > 0 and n0 > 0 | 0 ≤ f(n) ≤ c ⋅ g(n), ∀n ≥ n0 }
This means O(g(n)) is the set of all functions f(n) which grow slower than g(n) for some constant c and for n ≥ n0. In order to find n0 and c we use a justification like the following:
n²+3n + 2 ≤ n² + 3n² + 2n²
n²+3n + 2 ≤ 6n² for c = 6 and n ≥ 1
Now if you just use g(n) = n² obviously f(n) = n² + 3n + 2 will grow faster than g(n); but by choosing the value of c correctly g(n) will grow faster than f(n) for n ≥ n0.
a. f(N) = N and g(N) = N + N2
b. f(N) = 2N and g(N) = √N
c. f(N) = NlogN + N and g(N) = 2NlogN + N
d. f(N) = 2√N + N and g(N) = √N + N
What is the best way of calculating these functions, I have tried putting values into them, but some of them are very close in values and I am not sure which one to pick.
Calculate f(N)/g(N) in the limit N➡Infinity.
If f(N)/g(N) approaches a positive constant 𝛼 in the limit N➡Infinity, then f(N) ~ 𝛼 g(N).
How to get big-O for this?
T(N) = 2T(N − 1) + N, T(1) = 2
I got two variants of answer O(2^N) or O(N^2), but I am not sure how to solve it correctly
Divide T(N) by 2^N and name the result:
S(N) = T(N)/2^N
From the definition of T(N) we get
S(N) = S(N-1) + N/2^N (eq.1)
meaning that S(N) increases, but quickly converges to a constant (since N/2^N -> 0). So,
T(N)/2^N -> constant
or
T(N) = O(2^N)
Detailed proof
In the comment below Paul Hankin suggests how to complete the proof. Take eq.1 and sum from N=2 to N=M
sum_{N=2}^M S(N) = sum_{N=2}^M S(N-1) + sum_{N=2}^M N/2^N
= sum_{N=1}{M-1} S(N) + sum_{N=1}^{M-1} (N-1)/2^{N-1}
thus, after canceling terms with indexes N = 2, 3, ..., M-1, we get
S(M) = S(1) + sum_{N=1}^M N/2^N - M/2^M
and since the series on the right converges (because its terms are bounded by 1/N^2 for N>>1 which is known to converge), S(M) converges to a finite constant.
It's a math problem and Leandro Caniglia is right.
let b(n) = T(n) / 2^n
thus b(n) = b(n-1) + n / 2^n = b(n-2) + n / 2^n + (n-1) / 2^(n-1) ....
i / 2^i is less than 1 for every integer i
So the sum of them has limit and must smaller than some constant.
thus b(n) < C.
thus T(n) < 2^n * C.
It is obvious that T(n) >= 2^n.
So T(n) is O(2^n)
Check by plugging the answer in the equation.
2^N = 2.2^(N-1) + N = 2^N + N
or
N^2 = 2 (N-1)^2 + N
Keeping only the dominant terms, you have
2^N ~ 2^N
or
N^2 ~ 2 N^2.
Conclude.
Put these function in the ascending order of their growth in terms of n:
2^((log n)^0.5), 2^n, 2^(n/2), n^(4/3), n(log n)^3, n^(log n), 2^(n^2), n!
The way you solve this problem is by seeing which function approaches infinity fastest as n approaches infinity. Suppose you have some functions:
f(n) = n!
g(n) = n
h(n) = 3^n
You can compare any two functions by evaluating their ratio as n approaches infinity. For example:
Lim f(n) /
n->∞ / g(n)
If the result is greater than 1, then f(n) is asymptotically greater than g(n). If the result is 1, then they are asymptotically the same. If the result is less than one, then f(n) is asymptotically less than g(n).
You may find that some are easy to solve, like f(n) and g(n), and you can simplify the expression to get a definite value at the limit.
f(n) / = n! / = n (n-1)! / = (n-1)!
/ g(n) / n / n
The limit as n goes to infinity of this expression is infinity, which means that f(n) is asymptotically greater than g(n).
Other expressions are not as simple. If evaluating the limit gives you an indeterminite form, you need to use L'Hôpital's rule.
Lim g(n) / = Lim n / = ∞ /
n->∞ / h(n) n->∞ / 3^n / ∞
According to L'Hôpital's rule, we can evaluate a limit by substituting g'(n) and h'(n).
Lim g'(n) / = Lim 1 / = 1 /
n->∞ / h'(n) n->∞ / 3^n ln(3) / ∞
This limit is clearly less than 1, so we can say that g(n) is asymptotically less than h(n).
Partial answer: 2^((log n)^0.5), 2^(n/2), 2^n, n!, 2^(n^2).
Need to put these as well: n^(4/3), n(log n)^3, n^(log n)
What is the order relationship between f(n) = 10n and g(n) = n^(nmod6)?
I know that I can think of f(n) as just n, but thinking about g(n) confuses me because won't nmod6 change with the different values of n? For example, n = 6 would make g(n) = n^0 = 1 but when n = 5, g(n) = n ^ 5. How can I think of this with respect to the Big-Oh, Big-Theta, and Big-Omega relationships?
(n mod 6) can only take values from 0 to 5, so g(n) is bounded above by n^5, and bounded below by 1. So it would be O(n^5) and Omega(1). It does not have a workable Big-Theta.