HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Two increasing functions from the set of positive integers to the set of positive integers such that neither f (n) is O(g(n)) nor g(n) is O(f (n))

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
suchthepositiveintegerstwothatincreasingnorfunctionsfrom

Problem

Here is the question again : Give an example of two increasing functions f (n) and g(n) from the set of positive integers to the set of positive integers such that neither f (n) is O(g(n)) nor g(n) is O(f (n)).

I tried with several functions such as sine and cosine, but they are not increasing functions but Oscillatory. Then I tried x + sinx and x + cosx. However for sufficiently large coefficients c and n0, they also fail two satisfy the criteria. I am starting to doubt if such pairs of functions even exist !?

Solution

Take $f(n) = (2\lfloor\frac{n}{2}\rfloor+1)!$ and $g(n) = (2\lceil \frac{n}{2} \rceil)!$.

For example:
$$
\begin{array}{c|ccccc}
n&1&2&3&4&5 \\\hline
f(n)& 1! & 3! & 3! & 5! & 5! \\\hline
g(n)& 2! & 2! & 4! & 4! & 6!
\end{array}
$$
We have
$$
\frac{f(2m)}{g(2m)} = \frac{(2m+1)!}{(2m)!} = 2m+1 \to \infty
$$
as well as
$$
\frac{f(2m+1)}{g(2m+1)} = \frac{(2m+1)!}{(2m+2)!} = \frac{1}{2m+2} \to 0.
$$

Context

StackExchange Computer Science Q#131204, answer score: 3

Revisions (0)

No revisions yet.