Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Consider <code>S(n) = n^2</code> and <code>T(n) = n</code>. Then both <code>S</code> and <code>T</code> are <code>O(n^2)</code> but <code>S(n) / T(n) = n</code> which is not <code>O(1)</code>.</p> <p>Here's another example. Consider <code>S(n) = sin(n)</code> and <code>T(n) = cos(n)</code>. Then <code>S</code> and <code>T</code> are <code>O(1)</code> but <code>S(n) / T(n) = tan(n)</code> is not <code>O(1)</code>. This second example is important because it shows that even if you have a tight bound, the conclusion can still fail.</p> <p>Why is this happening? Because the obvious "proof" completely fails. The obvious "proof" is the following. There are constants <code>C_S</code> and <code>C_T</code> and <code>N_S</code> and <code>N_T</code> where <code>n &gt;= N_S</code> implies <code>|S(n)| &lt;= C_S * f(n)</code> and <code>n &gt;= N_T</code> implies <code>|T(n)| &lt;= C_T * f(n)</code>. Let <code>N = max(N_S, N_T)</code>. Then for <code>n &gt;= N</code> we have</p> <pre><code>|S(n) / T(n)| &lt;= (C_S * f(n)) / (C_T * f(n)) = C_S / C_T. </code></pre> <p><strong>This is completely and utterly wrong.</strong> It is not the case that <code>|T(n)| &lt;= C_T * f(n)</code> implies that <code>1 / |T(n)| &lt;= 1 / (C_T * f(n))</code>. In fact, what is true is that <code>1 / |T(n)| &gt;= 1 / (C_T * f(n))</code>. The inequality reverses, and that suggests there is a serious problem with the "theorem." The intuitive idea is that if <code>T</code> is "small" (i.e., bounded) then <code>1 / T</code> is "big." But we're trying to show that <code>1 / T</code> is "small" and we just can't do that. As our counterexamples show, the "proof" is fatally flawed.</p> <p>However, there is a theorem here that is true. Namely, if <code>S(n)</code> is <code>O(f(n))</code> and <code>T(n)</code> is <code>Ω(f(n))</code>, then <code>S(n) / T(n)</code> is <code>O(1)</code>. The above "proof" works for this theorem (thanks are due to <a href="https://stackoverflow.com/questions/7323349/division-operation-on-asymptotic-notation/7323520#7323520">Simone</a> for the idea to generalize to this statement).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload