liveBook · Manning

Combinatorial base representation

As explained in Fabulous Adventures in Data Structures and Algorithms

A combinatorial base representation expresses an integer as a sum of binomial coefficients with constrained upper indices.

A combinatorial base representation encodes an integer as a combination number: one of the values from 0 through (n choose k)−1. The encoding follows the lexicographic ordering of k-element combinations, with binomial coefficients dividing the search into ranges. section 6.3.2

To decode a value p, compare it with (n−1 choose k). If p falls below that boundary, exclude n−1; otherwise subtract the boundary and include n−1, then recurse on the smaller problem. section 6.3.2

Decoding a combination number

GetCombination(8, 6, 4) recursively partitions the combinations using binomial boundaries and returns the combination represented by rank 8. The same ordering appears in listings such as 0123, 0124, 0125, and 0134. section 6.3.2

How Fabulous Adventures in Data Structures and Algorithms covers it

How deep it goes
Defines the representation and sketches recursive decoding, while deferring the inverse combination-to-index method.
Examples
Uses ordered combinations such as 0123, 0124, 0125, and a decoder call with rank 8, n=6, and k=4.
What it assumes
Assumes familiarity with combinations, binomial coefficients, and lexicographic ordering.
What you can do after
Apply it via a recursive C# decoder that converts a combination number into its corresponding combination.
How it connects
Connects binomial coefficients, lexicographic ordering, combination ranking, and factorial base representation.

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.