0

If an algorithm requires C(n+r-1, r-1) steps to solve a problem, where n is the number of input, and r is a constant, does the steps of algorithm consider exponential growth?

william007
  • 17,375
  • 25
  • 118
  • 194

2 Answers2

1

Assuming that C is the binomial coefficient function: C(n + r - 1, r - 1) = (n + r - 1)! / ((r - 1)! * n!). Since r is a constant, we can disregard (r - 1)! when using the big-O notation, so we get O((n + r - 1)! / n!). I assume that this might be homework, so try to take it further from here by yourself. It is possible to reduce (n + r - 1)! / n! to a quite simple expression since it is inside of an O(), and you'll then easily see whether or not it is exponential. (Hint: how many factors are there in (n + r - 1)! / n!?)

Aasmund Eldhuset
  • 37,289
  • 4
  • 68
  • 81
  • 2
    Thanks, this is not a homework, and I am rephrasing some other of my working problem into this algorithmic problem. But from your tips, (n + r - 1)! / n!=(n+r-1)*...*(n+1)..which is O(n^(r-1)) meaning this is polynomial rather than exponential, am I right? – william007 Jul 16 '12 at 10:13
  • @william007: Correct - it is even _Theta(n^(r - 1))_. Note, though, that if the restriction that _r_ be constant is dropped, this would no longer be the case. – Aasmund Eldhuset Jul 16 '12 at 12:47
  • @william007: Glad to help. Out of curiosity, what was the original problem? – Aasmund Eldhuset Jul 16 '12 at 23:01
0

No. the complexity would be O(n^(r-1)) which is a polynomial growth instead of (and better than) exponential growth.

let g(n) = C(n+r-1, r-1) 
         = (n+r-1)! / ((r-1)!n!)  
         = (n+1)(n+2)...(n+r-2)(n+r-1) / (r-1)!
         = n^(r-1) + kn^(r-2) + k'n^(r-3)... k''n + k''' / (r-1)!

it's easy to say that k,k'...k'',k'''and (r-1)! are all constant,
so T(g(n)) = O(n^(r-1))
Timothy
  • 4,467
  • 5
  • 28
  • 51