Suppose
S(n) = Big-Oh(f(n)) & T(n) = Big-Oh(f(n))
both f(n)
identically belongs from the same class.
My ques is: Why S(n)/T(n) = Big-Oh(1)
is incorrect?
Consider S(n) = n^2
and T(n) = n
. Then both S
and T
are O(n^2)
but S(n) / T(n) = n
which is not O(1)
.
Here's another example. Consider S(n) = sin(n)
and T(n) = cos(n)
. Then S
and T
are O(1)
but S(n) / T(n) = tan(n)
is not O(1)
. This second example is important because it shows that even if you have a tight bound, the conclusion can still fail.
Why is this happening? Because the obvious "proof" completely fails. The obvious "proof" is the following. There are constants C_S
and C_T
and N_S
and N_T
where n >= N_S
implies |S(n)| <= C_S * f(n)
and n >= N_T
implies |T(n)| <= C_T * f(n)
. Let N = max(N_S, N_T)
. Then for n >= N
we have
|S(n) / T(n)| <= (C_S * f(n)) / (C_T * f(n)) = C_S / C_T.
This is completely and utterly wrong. It is not the case that |T(n)| <= C_T * f(n)
implies that 1 / |T(n)| <= 1 / (C_T * f(n))
. In fact, what is true is that 1 / |T(n)| >= 1 / (C_T * f(n))
. The inequality reverses, and that suggests there is a serious problem with the "theorem." The intuitive idea is that if T
is "small" (i.e., bounded) then 1 / T
is "big." But we're trying to show that 1 / T
is "small" and we just can't do that. As our counterexamples show, the "proof" is fatally flawed.
However, there is a theorem here that is true. Namely, if S(n)
is O(f(n))
and T(n)
is Ω(f(n))
, then S(n) / T(n)
is O(1)
. The above "proof" works for this theorem (thanks are due to Simone for the idea to generalize to this statement).
Here's one counter example:
Let's say f(n) = n^2
, S(n) = n^2
and T(n) = n
. Now both S and T are in O(f(n))
(you have to remember that O(n^2)
is a superset of O(n)
, so everything that's in O(n)
is also in O(n^2)
), but U(n) = S(n)/T(n) = n^2/n = n
is definitely not in O(1)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With