12

I have a recursive algorithm with time complexity equivalent to choosing k elements from n with repetition, and I was wondering whether I could get a more simplified big-O expression. In my case, $k$ may be greater than $n$ and they grow independently.

Specifically, I'd expect some explicit exponential expression. The best I could find so far is that based on Stirling's approximation $O(n!) \approx O((n/2)^n)$, so I can use that, but I wondered if I could get anything nicer.

$$O\left({{n+k-1}\choose{k}}\right) = O(?)$$

D.W.
  • 167,959
  • 22
  • 232
  • 500
yoniLavi
  • 245
  • 4
  • 10

2 Answers2

7

Edit: This answer is for $k<n$. Without bounding $k$ in terms of $n$ the expression is unbounded.

If $k=n-1$ then your expression becomes $O\left ({{2(n-1)}\choose{n-1}}\right)$. Notice that by Stirling's formula for any $0<\alpha<1$ $${m \choose {\alpha m}}= \Theta(m^{-{1/2}} 2^{H(\alpha)m}),$$ where $H(q)=-q \log q - (1-q) \log (1-q)$ is the binary entropy. In particular $H(1/2)=1$. Therefore we have for $k=n-1$ $$O\left ({{2(n-1)}\choose{n-1}}\right)=\Theta((2n-2)^{-{1/2}} 2^{2n-2})=\Theta\left(\frac{ 4^{n}}{\sqrt{n}}\right).$$

Since the upper bound $k=n-1$ is the worst case ( I leave it as an exercise to show this), your expression is $O\left(\frac{ 4^{n}}{\sqrt{n}}\right)$.

A.Schulz
  • 12,252
  • 1
  • 42
  • 64
2

Wolfram says Sondow (2005)[1] and Sondow and Zudilin (2006)[2] noted the inequality: $$\frac{1}{4rm}\left[\frac{(r+1)^{r+1}}{r^r}\right]^m < {(r+1)m \choose m} < \left[\frac{(r+1)^{r+1}}{r^r}\right]^m$$ for $m$ a positive integer and $r\ge 1$ a real number.

We can then use $${n+k-1\choose k} < {n+k\choose k} = {(r + 1)m \choose m}$$ with $r = \frac{n}{k}$ and $m = k$.

Then we have $${n+k-1\choose k} < \left[\frac{(r+1)^{r+1}}{r^r}\right]^m = \left(\frac{n+k}{k}\right)^{n+k}$$

Now, the binomial expression has the highest value at the middle of the Pascal's triangle. So, in our case, $n+k = 2k$ or at $k = n$.

Substituting that in the above inequality, we get: $${n+k-1\choose k} < 2^{2n} = 4^n$$.

Therefore, a tighter bound is $${n+k-1\choose k} = O(4^n)$$.

You can also see that the lower bound for the maximum value is $${n+k-1\choose k} = \Omega\left(\frac{4^n}{n}\right)$$

References:
[1] Sondow, J. "Problem 11132." Amer. Math. Monthly 112, 180, 2005.
[2] Sondow, J. and Zudilin, W. "Euler’s constant, q-logarithms, and formulas of Ramanujan and Gosper" Ramanujan J. 12, 225-244, 2006.

Paresh
  • 3,368
  • 1
  • 21
  • 33