I have written an algorithm that given a list of words, must check each unique combination of four words in that list of words (regardless of order).
The number of combinations to be checked, x
, can be calculated using the binomial coefficient i.e. x = n!/(r!(n-r)!)
where n
is the total number of words in the list and r
is the number of words in each combination, which in my case is always 4, therefore the function is x = n!/(4!(n-4)!) = n!/(24(n-4)!)
. Therefore as the number of total words, n
, increases the number of combinations to be checked, x
, therefore increases factorially right?
What has thrown me is that WolframAlpha was able to rewrite this function as x = (n^4)/24 − (n^3)/4 + (11.n^2)/24 − n/4
, so now it would appear to grow polynomially as n
grows? So which is it?!
Here is a graph to visualise the growth of the function (the letter x is switched to an l)
Binomial coefficients as polynomials As such, it can be evaluated at any real or complex number t to define binomial coefficients with such first arguments. These "generalized binomial coefficients" appear in Newton's generalized binomial theorem.
Properties of Binomial Theorem The number of coefficients in the binomial expansion of (x + y)n is equal to (n + 1). There are (n+1) terms in the expansion of (x+y)n. The first and the last terms are xn and yn respectively.
A binomial coefficient equals the number of combinations of r items that can be selected from a set of n items. It also represents an entry in Pascal's triangle. These numbers are called binomial coefficients because they are coefficients in the binomial theorem.
For a fixed value of r, this function is O(n^r). In your case, r = 4, it is O(n^4). This is because most of the terms in the numerator are canceled out by the denominator:
n!/(4!(n-4)!)
= n(n-1)(n-2)(n-3)(n-4)(n-5)(n-6)...(3)(2)(1)
-------------------------------------------
4!(n-4)(n-5)(n-6)...(3)(2)(1)
= n(n-1)(n-2)(n-3)
----------------
4!
This is a 4th degree polynomial in n.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With