Find the least integer n such that the specified function is O(x^n)
I think both functions are \(\large \mathcal{O(1)}\), so \(n = 0 \)
This class is going to kill me. I don't even understand to well that they want me to do :(
\[\large g(x) = \dfrac{(x^2+2)\log x + 3x^2}{2x^3-1}\] \[\large = \dfrac{\mathcal{O(x^2\log x)}}{\mathcal{O(x^3)}}\]
as the size of data, x, varies, the numerator complexity varies as x^2log(x) and the denominator complexity varies as x^3
we can disregard the -1 right?
nce all the terms are less than 1 coefficient hence the function will be O(1), since the maximum value of log(x) < x, hence big-oh of function will be O(X^0) and a = 0
is that right?
that looks good to me ^
for the second one.. what about this ..
a class mate says it is -1 ... as we ignore the -1 and associate the values
that the function would be O(X^-1)
i think so, -1 should be correct
but i don't understand how he gets to that conclusion :(
this class is so hard. I think I may have to drop it
\[\large h(x) = \dfrac{x^2+2}{2x^3\log x-1}\]
listen, its not that hard - tbh, idk these stuff, i just googled and discussing with you as they seem interesting
\[\large h(x) = \dfrac{x^2+2}{2x^3\log x-1}\] \[\large ~~= \dfrac{\mathcal{O(x^2)}}{O(x^3\log x)}\]
numerator complexity is x^2,
denominator complexity is atleast x^3logx = x^3x^k = x^(3+k) 0<k < 1
Overall function complexity is : 2-3-k = -1-k = -1.something
ceiling it to highest value gives -1
Hmm You explain so much better!
my book and class notes are so confusing . Even at 4 AM I understand you better! I see what you are doing.. it is like finding a bounding max function? right?
Exactly !
for example : complexity of \(\large f(x) = \dfrac{x^3+1}{2x}\) would be \(\large \mathcal{O(2)}\)
we move the integers... bring all the exponents in one line.. kinda the magic number!
2x and 1000000000x are same when we speak about complexity
both are polynomial time of order 1 (linear)
I feel this better now!
similarly, x^3 and x^3+2x are same
x^3 and x^3 + x^3 are also same
we look at the highest exponent ?
yes...
cool! Can I ask you one last help with this let me see if i get it
here the highest exponent is x^3... so it is 3rd order?
yes but thats already given, the problem wants you to prove it by finding the values of C and K
the definition is |f(x)| ≤ C|g(x)| for x ≥ k.
g(x) would be x^3 , right? bcs that is the variable with the highest exponent?
like this ? \[\large |2x^3+3x\log x| \le C|x^3|\]
I think so. I am not too sure what is the right f(x) to use
or how to move next
our goal is to find \(C\) that holds above inequality for all x = k > 1
\[\large |2x^3+3x\log x| \le C|x^3|\] \[\large \dfrac{|2x^3+3x\log x|}{|x^3|} \le C\]
\[\large |2x^3+3x\log x| \le C|x^3|\] \[\large \dfrac{2x^3}{x^3} + \dfrac{3x\log x}{x^3} \le C\] \[\large 2 + \dfrac{3\log x}{x^2} \le C\]
Cool. I follow that. so C is greater than 2 for sure!
make it : C >= 2+3 = 5 k >= 1
cos the upper bound of 3logx/x^2 is 3
is that because we are letting x = 1?
ahhh
yes i think you knw more about these things than me lol http://www.wolframalpha.com/input/?i=max+3log%28x%29%2Fx%5E2 C >= 2+1 = 3 k >= 1 will also work
but C>=2 will not work.
the minimum value for C to satisfy the initial inequality for all x=k>=1 is C = 3 ^
so k = 1 and c =3 ?
that works : http://www.wolframalpha.com/input/?i=solve+2x%5E3%2B3x%5Clog+x+%5Cle++3x%5E3+in+reals
awesome! I understand better now
thank you so much !
Are you familiar with recursion by any chance?
np :) try me...
This is even weirder lol
Basis : consider this 4 bit string \(\large "t010"\)
(btw you did great with the c = 3 :D you rock!! )
From the hypothesis, we have \(\large w="010" \in S \) Also from the hypothesis recursion step, we know that \(\large "0"w\) and \(\large "1"w\) also will lie in \(\large S\)
that means, all the strings with \(\large 1\) bit prefix substring (\(t\) ) will lie in \(S\) So the statement is true for \(1\) bit suffix substring \(t\)
that establishes the base case ^
that means a 0 left to w like 0010 and a 1 left to 1 like 1010 ?
let me know if something doesn't make sense
yes ! those are all the possible values for \(1\) bit suffix substring \(t\)
when t is 1 bit, t = 0 t = 1 are the only possible values
so "t010" covers all the possible 4 bit strings ending with 010
awesome!
thats the base case ^ now we need to make an assumption, for t = k, and go ahead with proving that the t = k+1 gives all possible strings as well
recall the basic structure of any induction proof : 1) prove n = 1 lies in the solution set 2) assume n=k lies in the solution set 3) prove that n=k+1 lies in the solution set, whenever n=l lies in the solution set.
we're done with step 1, so far
yes! that i do remember well
step2 : assumption/induction hypothesis Assume that for some prefix string \(t\) of length \(k\), all the strings ending with \("010"\) lie in \(S\)
so we use induction for recursion?
in simple words : \("t010"\) lies in \(S\) where \(t\) = all possible substrings of length \(k\)
the last step is to prove the \(k+1\) case using the induction hypothesis
step3 : prove k+1 case/induction step from the induction hypothesis \("t010" \in S\) from the given recursion step, \("0t010"\) and \("1t010"\) also will lie in \(S\) that means all the strings with prefix substrings of length \(k+1\) will lie in \(S\) QED.
guess its a simple proof, explanation is bit tricky o,o
lol but we need induction for recursion?
we did use plenty of induction above right ?
the question itself asked us to work it by induction, so..
that is true lol so sorry! I misread the second part !
let me put all the 3 steps in one place so it becomes easy to read
thanks! I think you are a wonderful human being! just so you know
*cries*
Statement to prove : prove that \(\large S\) contains all strings ending with \(\large 010\)
Step1 : Base case (show that \(\large "t010" \in S\) when the length of prefix substring equals \(\large 1\) From the hypothesis, we have \(\large "010" \in S\) Also from the hypothesis recursion step, we know that \(\large "0"010 \) and \("1"010\) also will lie in \(S\) that means, \(\large "t010" \in S\) when the length of prefix substring equals \(\large 1\)
Step2 : assumption/induction hypothesis (n=k case) Assume that for some prefix string \(\large t\) of length \(\large k\), all the strings ending with \(\large "010"\) lie in \(\large S\). In other words : \(\large "t010" \in S\) where \(t\) = all possible substrings of length \(k\)
Step3 : prove k+1 case/induction step from the induction hypothesis \(\large "t010"\in S\) from the given recursion step, \("0t010"\) and \("1t010"\) also will lie in \(S\) that means all the strings with prefix substrings of length \(k+1\) will lie in \(S\)
QED.
that looks like a mouthful, have fun :)
you are very kind! Now I am going to take the quiz which is kinda hard but you have helped me greatly ! thanks!
good luck !
Join our real-time social learning platform and learn together with your friends!