liveBook · Manning

Binomial coefficient

As explained in Fabulous Adventures in Data Structures and Algorithms

A binomial coefficient is the number of ways to choose a specified number of elements from a set of a given size.

A binomial coefficient counts the k-element combinations that can be selected from n items, written n C k and pronounced “n choose k.” It counts selections rather than arrangements, so order does not matter. section 6.3.2

Useful identities expose both boundary cases and an efficient computation:

  • n C k = 0 when k > n, while n C 0 = 1. section 6.3.2
  • n C k = n C (n − k), because choosing the selected items corresponds to choosing the unselected items. section 6.3.2
  • n C k = (n − 1) C (k − 1) + (n − 1) C k, dividing combinations according to whether they contain the final item. section 6.3.2
  • The direct product formula divides by k! to remove the ordering counted while selecting items sequentially. section 6.3.2

Computing and using a coefficient

A C# implementation uses BigInteger, replaces k with n − k when that is smaller, and multiplies and divides incrementally. Thus 20.Choose(10) evaluates the number of ten-element selections from twenty items.

How Fabulous Adventures in Data Structures and Algorithms covers it

How deep it goes
Develops boundary identities, symmetry, recurrence, product derivation, BigInteger implementation, and unranking.
Examples
Uses 20 choose 10, a C# Choose extension, and recursive recovery of a combination from its position.
What it assumes
Assumes combinations, permutations, factorials, and recursion while deriving the counting identities.
What you can do after
Apply it via a C# BigInteger implementation or use coefficients to recover combinations recursively.
How it connects
Connects combinations with permutations, recursion, factorials, and the Fisher–Yates shuffle.

Also explained in

Compare how 2 books explain binomial coefficient →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fabulous Adventures in Data Structures and Algorithms. The section links point to the parts of the book it draws on.