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)