Complexity analysis of m!/n!(m-n)!
-
29-09-2020 - |
Question
Given the runtime of an algorithm to be m!/(n!*(m-n)!) That is mCn, where both m and n are variables, is the complexity factorial or polynomial? Or is it something else?
Please elaborate.
Thanks
Solution
The growths could be linear or constant depending on the relationship between $m$ and $n$ as they grow large. For example, if $n$ grows with $m$ as in $m=n+1$, then $\binom{m}{n}=\binom{n+1}{n}=n+1$.
Now, if you are interested in the maximum growth, then the binomial coefficients $\binom{m}{n}$ are largest when $n$ is half of $m$. Put $m=2n$ and use Stirling's approximation for the factorial. You get
$$\binom{2n}{n}=\frac{(2n)!}{(n!)^2}\sim \frac{(2n)^{2n}e^{-2n}\sqrt{4n\pi}}{n^{2n}e^{-2n}2n\pi}=\pi^{-1/2}2^{2n}n^{-1/2}$$