How to understand big O, big omega and big theta statement? - data-structures

There is a question:
Which one of the following statements is TRUE?
A 15n^2 + 3n + 2 E O(n log2 n)
B. 15n^2 + 3n + 2 E n(n4)
C. 15n^2 + 3n + 2 E O(n3 )
D. 15n^2 + 3n + 2 E 0(15)
Some symbol is not shown correctly, hence I upload a screenshot for this
screentshot of question
I put all statement into graph as shown below:
graph of statements
I still can not figure out which is correct answer, 15n^2 + 3n + 2 is a sub-set for all option, I might misunderstand some definition, but I tried to search lots of, and I can not get any idea, can anyone help me, thanks!!!!!

Related

How to get O(n) from T(n) = T(n/2) + n?

I know that with master theorem i'll have teta(n), but i'm trying to resolve the recurrence in other way like this:
T(n) = T(n/2) + n
T(n) = T(n/4) + 2n
T(n) = T(n/8) + 3n
.
.
.
T(n) = T(n/2^k) + kn
k=logn -> T(1) + **nlogn**
what's the problem?
There are two steps involved in solving a recurrence relation from scratch:
Somehow find the answer
Prove that it's correct
The "Somehow find the answer part" can be hard. Usual ways are to expand a few terms and extrapolate, like Rodojf did in the other answer, graph/table it out and eyeball it, or recognize a familiar pattern. All of those ways work pretty well for your example.
Let's put a few points in a table or graph (letting C = T(1)):
n | T(n)
===========
1 | C
2 | C + 2
4 | C + 6
8 | C + 14
16 | C + 30
Looks to me like T(n) = 2n - 2 + C
We can prove T(2x) = 2x+1 - 2 + C to be correct for all x>=0 by induction:
If x=0, then 2x+1 - 2 + C = C, so T(2x) = 2x+1 - 2 + C, from the table
For any x, T(2x) = 2x+1 - 2 + C ⇒ T(2x+1) = 2x+1 - 2 + C + 2x+1 = 2(x+1)+1 - 2 + C, by substitution
So the fact that the formula is correct for n=20 implies that it is correct for all n=2x
To cover all the other values of n, you should also note that there is always some 2x between n and 2n, and between n/2 and n, and that their values of T(2x) bound T(n).
This is a fair bit of work for one single case... which is why we remember the master theorem, which has been proven for all of the cases that match its patterns.
T(n)=T(n/2)+n=T(n/2^2)+n/2+n=T(n/2^3)+n/2^2+n/2+n= ... =
=T(n/2^k)+n/2^(k-1)+n/2^(n-2)+...+n=
=T(n/2^k)+n*(1-(1/2)^k)/(1-1/2)=
=T(n/2^k)+2*n*(1-(1/2)^k)<=
<=T(n/2^k)+2*n
If you know that T is a function defined and bounded in (0,0+e) for some small e>0 then you can conclude that T is O(n).
In the last chapters of Foundations of Algorithms - Richard E. Neapolitan.pdf you find several way to solve recurrence relation .
some way like :
1- recurrence tree
2- change variable and differential equations
and also you can see link

How to prove using big-O

Im currently having a problem with big O notation. I have the following question which I am trying to figure out.
I currently have the formula: T(n) is O(f(n)) and I must use this to prove directly from the definition of big O that 3n^2+11n+6 is O(n^2).
I was wondering if anybody could possibly help me figure out this problem as I am having trouble working it out.
I think this may help:
For n≥k, there is a constant, let's name it "c" which satisfies 3n^2 + 11n + 6 ≤ c∗n^2.
Let's say we pick k = 1.
We know that n^2 ≥ n^2 ≥ n ≥ 1
So :
3n^2 + 11n + 6 ≤ 3n^2 + 11n^2 + 6n^2 =>3n^2 + 11n + 6 ≤ 20n^2
Now, let c = 20.
=>complexity is O(n2).

Big O Proof by Induction With Summation

I've been ripping my hair out trying to solve this:
Σ(k=0,n)3k = O(3n)
I've been looking through various things online but I still can't seem to solve it. I know it involves the formal definition of Big O, where
|f(x)| <= C*|g(x)|, x>=k
Since they are the same, I am assuming C is some value I have to find through induction to prove the original statement, and that k=0.
Thanks for your help with this.
Σ(k=0,n)3k
= 30 + 31 + ... + 3n
= (1 - 3n+1) / (1 - 3) ; sum of geometric series
= (3/2)*3n - k
<= c*3n ; for c >= 3/2
= O(3n)
Induction is not needed here; that sum is a geometric series and has closed form solution
= 1(1-3^(n + 1))/(1-3) = (3^(n + 1) - 1)/2
= (3*3^n - 1)/2
Pick C = 3/2 and F = 3/2*3^n - 1/2, G = 3^n, and this satisfies the requirement for O(3^n), but really in practice, though it might be thought informal and sloppy, you don't really worry much about an exact constant since any constant will do for satisfying Big-O.
You can rewrite it as 3n * ( 1 + 1/3 + 1/9 + ....1/3n).
There is an upper bound for that sum. Calculate the limit of that infinite series.
From there, it's easy to get a good C, eg: 2.

Recurence related to master theorem T(n)=T(n^(1/2))+1

In masters theorem were given a "plug-in" formula to find the big O, given it satisfies some condition.
However, what if we have problems like the following below? Can anyone show me how to do a step by step formula. And what topics would help me to know more about these types of questions. Assume that the person asking this question knows nothing about induction.
T(n)=T(n^(1/2))+1
T(n)=T(n-1) + 1
T(n)=T(n-1) + n^c , c is a natural number >1
T(n)= T(n-1) C^n, c is a natural number >1
You'll need to know a little math to do some of these. You can figure out what the recursion looks like when you expand it out all the way to the base case, e.g. for T(n) = T(n-1) + n^c you get T(n) = 1^c + 2^c + ... + n^c, but then you need to know some math in order to know that this is O(n^(c+1)). (The easiest way to see this is by bounding the sum above and below in terms of integrals of x^c). Similarly for T(n) = T(n-1) + c^n you easily get T(n) = c^1 + c^2 + ... + c^n but you again need to use some calculus or something to figure out that this is T(n) = O(c^n).
For T(n) = T(n^(1/2)) + 1 you need to count how many times you apply the recurrence before you get to the base case. Again math helps here. When you take square-root, the logarithm gets cut in half. So you want to know how many times you can cut the logarithm in half until you get to the base case. This is O(log log n).
You can expand upon the formula and work on it:
For example:
T(n) = T(n-1) + 1
T(n) = [T(n-2) + 1] + 1
...
T(n) = 1 + 1 + 1 ... (n times)
So T(n) = O(n).

Karatsuba Algorithm in Big O n^(lg3) proof by substitution

Karatsuba Algorithm involves the recursion relation T(n) = 3T(n/2) + n.
By the recursion tree method, we can approximate the big O of T to be O(nlog23)
However, by the substitution method I am having trouble verifying the approximate result I found by the recursion tree method
I'll simply use lg 3 to mean log23.
Substitution method:
Hypothesis -> T(n) <= cnlg 3 where c is a positive constant
Proof -> T(n) <= 3c(n/2)lg 3 + n
= cnlg 3 + n
But step 2 of the proof shows that I cannot prove my hypothesis because of n term.
I modified step 2 of proof
T(n) <= cnlg 3 + nlg 3
= (c+1)nlg 3
And later realized I had made a mistake because the hypothesis is not proven.
T(n) <= cnlg 3 has to be proven, not T(n) <= (c+1)nlg 3
But the answer is T(n) is O(nlg 3)
When using the substitution method, you sometimes have to strengthen the inductive hypothesis and guess a more complex form of the expression that upper-bounds the recurrence.
Try making a guess of the form T(n) ≤ c0 nlg 3 - c1n. Now that you are subtracting some term of the form c1 n, you can probably make the recurrence work out by using some of the linear term to offset the n term added in later.
For example:
T(n) ≤ 3T(n / 2) + n
≤ 3(c0(n/2)lg 3 - c1(n/2)) + n
= 3(c0(n/2)lg 3) - 3c1n/2 + n
Now, choose c1 so that -3c1n/2 + n = -c1n. This solves to
-3c1n/2 + n = -c1n
-3c1/2 + 1 = -c1
-3c1 + 2 = -2c1
2 = c1
This choice of c1 will then let you cancel out the +n term successfully, letting the induction work successfully.
Hope this helps!

Resources