English
How to Prove That \$O(n) Cdot O(n^2) = O(n^3)\$?

First, there seems to be some confusion about what you are asked to prove: what does \$\$tag1 O(n) cdot O(n^2) = O(n^3)\$\$ mean, exactly?The interpretation I am familiar with, in the words of Cormen et al., is the following:(Cormen et al., "Introduction to Algorithms", 3rd Ed., section 3.1, page 50.)Note how this makes the \$;=;\$ operator asymmetrical. Note also that this makes \$;f(n) = O(g(n));\$ mean \$;f in O(g(n));\$.\$%

equirebegingroup begingroup

ewcommandendcalcendalign

ewcommandReftext(#1)

ewcommandthenRightarrow

ewcommandwhenLeftarrow %\$This interpretation says that \$Ref1\$ is equivalent to: \$\$ beginalign& langle forall f,g :: f in O(n) ;land; g in O(n^2) ;then; &phantomlangle forall f,g ::; langle exists h :: h in O(n^3) ;land; langle forall n :: f(n) cdot g(n) = h(n)

angle

angle

angle endalign \$\$ or simplified: for all \$;f,g;\$, \$\$ tag1a f(n) = O(n) ;land; g(n) = O(n^2) ;then; f(n) cdot g(n) = O(n^3) \$\$Now, how would we prove \$Ref1a\$? You have the correct idea essentially, and let's try to write this down as cleanly as possible, using the definition that you seem to be using, which is \$\$ tag2 f(n) = O(g(n)) ;equiv; langle exists c : c > 0 : langle forall_textlarge enough n :: f(n) le c cdot g(n)

angle

angle \$\$It seems simplest to start with \$;f(n) cdot g(n);\$, and rewrite that using the assumptions in the left hand side of \$Ref1a\$:\$\$calc f(n) cdot g(n) ople_forall_textlarge enough nhintsusing the LHS of \$Ref1a\$ and definition \$Ref2\$ twice,hintchoose \$;c_1,c_2 > 0;\$ c_1 cdot n cdot c_2 cdot n^2 op=hintarithmetic (c_1 cdot c_2) cdot n^3 op=hintusing definition \$Ref2\$ with \$;c := c_1 cdot c_2;\$ O(n^3) endcalc\$\$By transitivity of the three steps, this proves \$Ref1a\$.A side note: The above proof of course does not just work for \$;n;\$ and \$;n^2;\$, but for any functions \$;F(n),G(n);\$: in the same way we can prove the more general \$\$tag3 O(F(n)) cdot O(G(n)) = O(F(n) cdot G(n))\$\$Finally, what about proving the other direction? I would write this as \$\$tag4 O(n^3) = O(n) cdot O(n^2)\$\$ and Cormen et al. says this means we need to prove beginalign tag4a &langle forall f :: f in O(n^3) ;then; &phantomlangle forall f :: ; langle exists g,h :: g in O(n) land h in O(n^2) land &phantomlangle forall f :: langle exists g,h :: ; langle forall n :: f(n) = g(n) cdot h(n)

angle

angle

angle endalignSo given an \$;f in O(n^3);\$, there seem to be two simple choices, one of which is \$;g(n) = f(n) / n^2;\$, and \$;h(n) = n^2;\$. All that is then left to prove is \$;f(n)/n^2 = O(n);\$ and \$;n^2 = O(n^2);\$, which are easy exercises from definition \$Ref2\$.(Note that I am assuming here that \$;n;\$ ranges over positive integers, to avoid technical manipulations to avoid division by zero.)And again, of course this proof generalizes immediately to a proof of \$\$O(F(n) cdot G(n)) = O(F(n)) cdot O(G(n))\$\$The only qualm I have with this proof is that it is not really symmetrical in \$;g;\$ and \$;h;\$: we could have equally well have chosen \$;g(n) = n;\$ and \$;h(n) = f(n) / n;\$. I tried to find a more symmetrical choice for \$;g,h;\$, but do not see it yet.\$% endgroup %\$

1. Is the chemical form of rust Fe2O3.xH2O?

Yes, chemical form of rust is Fe2O3.XH2O, where the number of water molecules is variable.Is the chemical form of rust Fe2O3.XH2O?

2. ( o _ 0 ) What is Shaquille O'Neal smoking these days?

I've seen him practice BJJ and he LOVES MMA but I think he is kinda nuts if he does this. I would hate to see him raped but I do like seeing these athletes thinking they can fight PROFESSIONAL MMA FIGHTERS and then die trying

3. I feel.. *big* and uncomfortable at school? Same weight as Debby Ryan o.O?

First of all I like how you are admitting a problem you have. Anyway, I like to take fresh walks every now and then. Eating a snack such as a piece of fruit helps too. Just watch what you eat, and keep it steady. The more patience, the better. Wish you very good luck :) Joel

latest articles
latest topics
latest products
related searches