Warm tip: This article is reproduced from stackoverflow.com, please click
algorithm math sorting big-o

Show 2^n is O(n!)

发布于 2020-03-29 21:03:42

I am struggling to understand why they are equal. Help would be appreciated. I have tried saying how 2^n implies doubling n times but I am not sure how that is similar to a factorial.

Questioner
StrugglingStudent202
Viewed
90
trincot 2020-01-31 19:02

To prove that 2n is O(n!), you need to show that 2n ≤ M·n!, for some constant M and all values of n ≥ C, where C is also some constant.

So let's choose M = 2 and C = 1.

For n = C, we see that 2n = 2 and M·n! = 2, so indeed in that base case the 2n ≤ M·n! is true.

Assuming it holds true for some n (≥ C), does it also hold for n+1? Yes, because if 2n ≤ M·n! then also 2n+1 ≤ M·(n+1)!

The left side gets multiplied with 2, while the right side gets multiplied with at least 2.

So this proves by induction that 2n ≤ M·n! for all n ≥ C, for the chosen values for M and C. By consequence 2n is O(n!).