Question

I'm reading Introduction to Algorithms 3rd Edition (Cormen and Rivest) and on page 69 in the "A brute-force solution" they state that n choose 2 = Theta (n^2). I would think it would be in Theta (n!) instead. Why is n choose 2 tightly bound to n squared? Thanks!

Was it helpful?

Solution

n choose 2 is

n(n - 1) / 2

This is

n2 / 2 - n/2

We can see that n(n-1)/2 = Θ(n2) by taking the limit of their ratios as n goes to infinity:

limn → ∞ (n2 / 2 - n / 2) / n2 = 1/2

Since this comes out to a finite, nonzero quantity, we have n(n-1)/2 = Θ(n2).

More generally: n choose k for any fixed constant k is Θ(nk), because it's equal to

n! / (k!(n - k)!) = n(n-1)(n-2)...(n-k+1) / k!

Which is a kth-degree polynomial in n with a nonzero leading coefficient.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top