Is n! in O(4^n) or 4^n in O(n!)?

  • MHB
  • Thread starter shamieh
  • Start date
  • Tags
    identities
In summary: This can be done by simply choosing an $n$ that is larger than $n_0$ and larger than any choice of $C$.In summary, the identities $n! = O(4^n)$ and $4^n = O(n!)$ were discussed, with the latter being true and the former being false. The definition of $f(n) = O(g(n))$, which states that for positive constants $C$ and $n_0$, $f(n) \leq Cg(n)$ for all $n \geq n_0$, was used to prove these identities. The negation of this definition was also explained, and it was shown that in order to prove $n! \notin O(
  • #1
shamieh
539
0
Which of the following identities are true. Justify your answer.
a)$n! = O(4^n)$
b)$4^n = O(n!)$

I have NO clue what to do here. First I was thinking let $n = 0$ so that $1 = O(1)$ (constant time complexity?)
 
Technology news on Phys.org
  • #2
It holds that:$$n!=1 \cdot 2 \cdots (n-1) \cdot n \geq 1 \cdot 2 \cdot 3 \cdot 4 \cdot 4 \cdots 4=1 \cdot 2 \cdot 3 \cdot 4^{n-3} \geq \frac{3}{32} \cdot 4^n$$

What can we deduce from that?
 
  • #3
Here is what I've came up with..

I know that: $f(x) = O(g(x))$ iff $\exists$ positive constants $C$ and $n_0$ $|0 \le f(n) \le c * g(n),$ $\forall$ $n \ge n_0|$

So I found that $n! \notin O(4^n)$ by letting $n = 10$ and letting $c = 1$. Then I found that $4^n \in O(4^n)$ is that the correct way to say it? Basically I found that the second identity is true.
 
  • #4
shamieh said:
Here is what I've came up with..

I know that: $f(x) = O(g(x))$ iff $\exists$ positive constants $C$ and $n_0$ $|0 \le f(n) \le c * g(n),$ $\forall$ $n \ge n_0|$

So I found that $n! \notin O(4^n)$ by letting $n = 10$ and letting $c = 1$. Then I found that $4^n \in O(4^n)$ is that the correct way to say it? Basically I found that the second identity is true.

I agree that the second identity holds, but the first doesn't.
You can prove that $4^n=O(n!)$ as I did in my previous post.
I think that in order to prove that $n! \notin O(4^n)$ you have to show the negation of the definition you stated.
The negation of $\forall$ is $\exists$ and conversely. So you just have to find a $n$ such that the relation doesn't hold for any $c$.
 
  • #5
shamieh said:
Then I found that $4^n \in O(4^n)$
This is trivially true because $f(n)\in O(f(n))$ for every $f$: just take $C=1$ and $n_0=0$.

evinda said:
The negation of $\forall$ is $\exists$ and conversely. So you just have to find a $n$ such that the relation doesn't hold for any $c$.
To elaborate on this, the definition of $f(n)\in O(g(n))$ says
\[
\exists C\,\exists n_0\forall n\ge n_0\;f(n)\le Cg(n).
\]
The negation of this is
\[
\forall C\,\forall n_0\,\exists n\ge n_0\;f(n)>Cg(n).
\]
So to prove that $n!\notin O(4^n)$ using the definition, you need to find an $n$ for every $C$ and $n_0$.
 

FAQ: Is n! in O(4^n) or 4^n in O(n!)?

What does the notation O(n) mean in this context?

The notation O(n) represents the order of growth or complexity of a function, specifically how the function's runtime or space requirement scales with the input size n.

Why is the identity n = O(4n) true?

This identity is true because as n increases, 4n will also increase at the same rate. Therefore, n is always less than or equal to 4n, making n = O(4n) true.

How do you justify the answer that n = O(4n) 4 n = O(n) is true?

We can justify this answer by using the formal definition of Big O notation, which states that for a function f(n) to be O(g(n)), there must exist a positive constant c and an input size n0 such that f(n) ≤ cg(n) for all n ≥ n0. In this case, we can choose c = 4 and n0 = 1, and the inequality is clearly satisfied for both n = O(4n) and 4n = O(n).

Can you provide an example to demonstrate that n = O(4n) 4 n = O(n) is true?

Sure, let's take the function f(n) = n and g(n) = 4n. As n increases, both f(n) and g(n) will increase at the same rate. For example, when n = 10, f(n) = 10 and g(n) = 40. Therefore, n = O(4n) and 4n = O(n) because f(n) is always less than or equal to 4g(n).

What is the implication of this identity in terms of algorithm analysis?

This identity tells us that n and 4n have the same order of growth or complexity. In terms of algorithm analysis, this means that algorithms with a runtime of O(n) and O(4n) will have the same efficiency and will scale at the same rate. Therefore, we can say that these two algorithms have equal performance.

Similar threads

Replies
1
Views
1K
Replies
1
Views
1K
Replies
1
Views
1K
Replies
1
Views
761
Replies
1
Views
1K
Replies
2
Views
1K
Replies
15
Views
2K
Replies
8
Views
2K
Replies
5
Views
1K
Back
Top