Chapter

Bijections and Encoding Objects

This module teaches bijective correspondences: subsets and strings, paths and words, compositions and bars, partitions and diagrams, and Catalan-style reflections.
Log in to track solved progress and bookmarks.

Theory

Key Idea

A bijection proves that two sets have the same size without computing both sizes separately. One must build a rule that assigns to every object of the first type exactly one object of the second type, and conversely.

In olympiad combinatorics, a bijection often turns an inconvenient object into a code: a path into a word, a subset into a binary string, a distribution into stars and bars, or a partition into a diagram.

Basic Facts

  • Subsets of an \(n\)-element set are in bijection with binary strings of length \(n\).
  • Monotone paths from \((0,0)\) to \((a,b)\) are in bijection with words containing \(a\) letters \(R\) and \(b\) letters \(U\).
  • Nonnegative solutions of \(x_1+\cdots+x_k=n\) are in bijection with strings of \(n\) stars and \(k-1\) bars.
  • Taking complements gives a bijection between \(k\)-subsets and \((n-k)\)-subsets.
  • Reflection of bad paths often gives exact formulas for Catalan-style restrictions.

When to Use This Method

Use it when the answer looks simple but direct counting is bulky; when a combinatorial identity must be proved; when objects can be encoded by sequences of choices; or when paths, parentheses, partitions, or selections without adjacent elements appear.

How to Recognise the Method

Signals include: “prove the two numbers are equal”, “find the number of ways” for very different-looking objects, “word/path/subset/distribution”, “no adjacent elements”, “not above the diagonal”, and “partition into parts”. A useful question is: what data must be recorded to reconstruct the object?

Typical Mistakes

  • Building a map without proving that it is reversible.
  • Losing objects with zero parts in stars and bars.
  • Treating a path and a word as “similar” without specifying the exact step correspondence.
  • In reflection arguments, reflecting from the wrong point instead of the first forbidden step.
  • Confusing ordered compositions with unordered partitions.

Mini-Checklist

  • Describe the left object and the right object.
  • State the forward map.
  • Show how to reconstruct the original object.
  • Check boundary cases: zeros, empty blocks, extreme paths.
  • If there is a restriction, try a bijection with bad objects or a reflection.

Examples

Example 1. Subsets and Binary Strings

The simplest bijection: an object is replaced by a zero-one code.

Problem. Prove that an \(n\)-element set has exactly \(2^n\) subsets.

Solution.

Number the elements \(1,\ldots,n\). To each subset assign a binary string of length \(n\): the \(i\)-th position is \(1\) if element \(i\) is chosen, and \(0\) otherwise. The subset can be uniquely recovered from the string. Hence the number of subsets equals the number of binary strings, which is \(2^n\).

Comment. Reversibility matters: the string does not merely come from the subset; it completely determines it.

Example 2. Paths and Words

A lattice path is naturally encoded by its sequence of steps.

Problem. How many monotone paths go from \((0,0)\) to \((4,3)\), using only steps right and up?

Solution.

Each path consists of \(4\) steps \(R\) and \(3\) steps \(U\). Recording the steps in order gives a word of length \(7\) with four \(R\)'s and three \(U\)'s. Conversely, every such word gives a path. Therefore the number of paths is \(\binom{7}{3}=35\).

Comment. This is the basic “path ↔ word” bijection.

Example 3. Stars and Bars

A distribution of identical objects into distinct boxes is encoded by bars.

Problem. How many nonnegative solutions does \(x_1+x_2+x_3+x_4=12\) have?

Solution.

Write \(12\) stars in a row and insert \(3\) bars. The number of stars before the first bar is \(x_1\), between the first and second is \(x_2\), between the second and third is \(x_3\), and after the third is \(x_4\). Adjacent bars are allowed and give zero parts. Thus we choose positions of \(3\) bars among \(15\) symbols, giving \(\binom{15}{3}=455\).

Comment. This is the source of many composition problems.

Example 4. Selection Without Neighbours

A no-adjacency restriction often disappears after shifting indices.

Problem. How many \(k\)-element subsets of \(\{1,\ldots,n\}\) contain no two consecutive numbers?

Solution.

Let the chosen numbers be \(1\le a_1<\cdots

Comment. This is a shifting bijection, not just a formula.

Example 5. Complements

Sometimes the bijection is so simple that it is easy to miss.

Problem. Prove combinatorially that \(\binom nk=\binom n{n-k}\).

Solution.

To each \(k\)-element subset \(A\), assign its complement \([n]\setminus A\), which has \(n-k\) elements. The inverse map is the same operation, since the complement of the complement is the original set. Hence the two sets have equal size.

Comment. This is a good example of an involutive bijection.

Example 6. Ferrers Diagrams

Partitions are often handled by reflecting or transposing diagrams.

Problem. Prove that the number of partitions of \(n\) into at most \(k\) parts equals the number of partitions of \(n\) in which every part is at most \(k\).

Solution.

Draw the partition as a Ferrers diagram: rows consist of cells, and row lengths are the parts. If there are at most \(k\) rows, then after transposing the diagram, every row of the new diagram has length at most \(k\). The inverse transformation is the same transposition. Thus we get a bijection.

Comment. A diagram is helpful, but the idea is an invertible transformation.

Example 7. Reflection of Bad Paths

The first serious Catalan-style move.

Problem. How many paths from \((0,0)\) to \((n,n)\), using \(R,U\), never go above the diagonal \(y=x\)?

Solution.

There are \(\binom{2n}{n}\) paths in total. A bad path first goes above the diagonal with a step \(U\), landing at a point with \(y=x+1\). Reflect the part of the path up to this first crossing in the line \(y=x+1\). This gives a path from \((-1,1)\) to \((n,n)\), i.e. a word with \(n+1\) steps \(R\) and \(n-1\) steps \(U\). There are \(\binom{2n}{n-1}\) bad paths. Hence the number of good paths is \(\binom{2n}{n}-\binom{2n}{n-1}=\frac{1}{n+1}\binom{2n}{n}\).

Comment. The key is to reflect up to the first violation.

Example 8. Prüfer Code

A strong bijection: a tree becomes a sequence.

Problem. State the idea of Prüfer coding for counting trees on vertices \(1,\ldots,n\).

Solution.

While the tree has more than two vertices, remove the leaf of smallest label and record the label of its neighbour. This gives a sequence of length \(n-2\) with entries in \(1,\ldots,n\). Conversely, from such a sequence, repeatedly take the smallest label not currently appearing in the sequence, connect it to the first sequence entry, and delete that first entry. At the end connect the two remaining vertices. This is a bijection between labelled trees and sequences of length \(n-2\), so there are \(n^{n-2}\) trees.

Comment. This is a Level 5 tool, but students should see it here.

Problems

Problems

#3.1
#3.1

Subsets as Strings

Subsets Grade 8 Grade 9 ★★☆☆☆

Construct a bijection between subsets of \(\{1,\ldots,n\}\) and binary strings of length \(n\). Conclude that there are \(2^n\) subsets.

Details
Problem: COM-B2-M03-P001
Difficulty: Level 2 of 5
Tag: Subsets
Grade: Grade 8, Grade 9
#3.2
#3.2

Paths as Words

Bijection Grade 8 Grade 9 ★★☆☆☆

How many monotone paths go from \((0,0)\) to \((5,4)\), using only right and up steps?

Details
Problem: COM-B2-M03-P002
Difficulty: Level 2 of 5
Tag: Bijection
Grade: Grade 8, Grade 9
#3.3
#3.3

Nonnegative Solutions

Stars and Bars Grade 8 Grade 9 ★★☆☆☆

How many nonnegative integer solutions does \(x_1+x_2+x_3=10\) have?

Details
Problem: COM-B2-M03-P003
Difficulty: Level 2 of 5
Tag: Stars and Bars
Grade: Grade 8, Grade 9
Source: com_3.md (method inspiration)
#3.4
#3.4

Positive Solutions

Stars and Bars Grade 8 Grade 9 ★★☆☆☆

How many positive integer solutions does \(x_1+x_2+x_3+x_4=17\) have?

Details
Problem: COM-B2-M03-P004
Difficulty: Level 2 of 5
Tag: Stars and Bars
Grade: Grade 8, Grade 9
#3.5
#3.5

Complement of a Subset

Complement method Grade 8 Grade 9 ★★☆☆☆

Prove combinatorially that \(\binom{n}{k}=\binom{n}{n-k}\).

Details
Problem: COM-B2-M03-P005
Difficulty: Level 2 of 5
Tag: Complement method
Grade: Grade 8, Grade 9
#3.6
#3.6

Even and Odd Are Equal

Parity Grade 9 Grade 10 ★★★☆☆

Prove that for an \(n\)-element set with \(n\ge1\), the number of even-sized subsets equals the number of odd-sized subsets.

Details
Problem: COM-B2-M03-P006
Difficulty: Level 3 of 5
Tag: Parity
Grade: Grade 9, Grade 10
#3.7
#3.7

Pascal Identity

Subsets Grade 9 Grade 10 ★★★☆☆

Prove by bijection the identity \(\binom{n}{k}=\binom{n-1}{k}+\binom{n-1}{k-1}\).

Details
Problem: COM-B2-M03-P007
Difficulty: Level 3 of 5
Tag: Subsets
Grade: Grade 9, Grade 10
#3.8
#3.8

Path Through a Point

Bijection Grade 9 Grade 10 ★★★☆☆

How many monotone paths from \((0,0)\) to \((7,5)\) pass through \((3,2)\)?

Details
Problem: COM-B2-M03-P008
Difficulty: Level 3 of 5
Tag: Bijection
Grade: Grade 9, Grade 10
#3.9
#3.9

Lower Bounds

Stars and Bars Grade 9 Grade 10 ★★★☆☆

How many integer solutions does \(x_1+x_2+x_3+x_4=30\) have if \(x_1\ge2\), \(x_2\ge4\), \(x_3\ge0\), \(x_4\ge5\)?

Details
Problem: COM-B2-M03-P009
Difficulty: Level 3 of 5
Tag: Stars and Bars
Grade: Grade 9, Grade 10
#3.10
#3.10

No Consecutive Numbers

Subsets Grade 9 Grade 10 ★★★☆☆

How many \(5\)-element subsets of \(\{1,\ldots,18\}\) contain no consecutive numbers?

Details
Problem: COM-B2-M03-P010
Difficulty: Level 3 of 5
Tag: Subsets
Grade: Grade 9, Grade 10
#3.11
#3.11

Partitions and Transposition

Bijection Grade 9 Grade 10 ★★★☆☆

Prove that the number of partitions of \(n\) into at most \(k\) parts equals the number of partitions of \(n\) in which each part is at most \(k\).

Details
Problem: COM-B2-M03-P011
Difficulty: Level 3 of 5
Tag: Bijection
Grade: Grade 9, Grade 10
#3.12
#3.12

Compositions and Separators

Stars and Bars Grade 9 Grade 10 ★★★☆☆

Prove that the number of ways to write \(n\) as a sum of \(k\) positive integers, with order taken into account, is \(\binom{n-1}{k-1}\).

Details
Problem: COM-B2-M03-P012
Difficulty: Level 3 of 5
Tag: Stars and Bars
Grade: Grade 9, Grade 10
Source: com_3.md (method inspiration)
#3.13
#3.13

Path Below the Diagonal

Reflection Grade 9 Grade 10 ★★★★☆

Find the number of paths from \((0,0)\) to \((n,n)\), using \(R,U\), that never go above the line \(y=x\).

Details
Problem: COM-B2-M03-P013
Difficulty: Level 4 of 5
Tag: Reflection
Grade: Grade 9, Grade 10
#3.14
#3.14

Ballot Count

Reflection Grade 10 Grade 11 ★★★★☆

Let \(p>q\). How many words with \(p\) letters \(A\) and \(q\) letters \(B\) have the property that in every initial segment, the number of \(A\)'s is strictly greater than the number of \(B\)'s?

Details
Problem: COM-B2-M03-P014
Difficulty: Level 4 of 5
Tag: Reflection
Grade: Grade 10, Grade 11
#3.15
#3.15

Parentheses and Paths

Bijection Grade 9 Grade 10 ★★★★☆

Construct a bijection between correct parenthesis sequences with \(n\) pairs of parentheses and paths from \((0,0)\) to \((n,n)\) that never go above the diagonal \(y=x\).

Details
Problem: COM-B2-M03-P015
Difficulty: Level 4 of 5
Tag: Bijection
Grade: Grade 9, Grade 10
#3.16
#3.16

Distinct and Odd Parts

Bijection Grade 10 Grade 11 ★★★★☆

Prove that the number of partitions of \(n\) into distinct parts equals the number of partitions of \(n\) into odd parts.

Details
Problem: COM-B2-M03-P016
Difficulty: Level 4 of 5
Tag: Bijection
Grade: Grade 10, Grade 11
#3.17
#3.17

An Involution for an Alternating Sum

Binomial Coefficients Grade 10 Grade 11 ★★★★☆

Give a bijective proof that \(\sum_{k=0}^{n}(-1)^k\binom nk=0\) for \(n\ge1\).

Details
Problem: COM-B2-M03-P017
Difficulty: Level 4 of 5
Tag: Binomial Coefficients
Grade: Grade 10, Grade 11
#3.18
#3.18

Prüfer Code

Graphs Grade 10 Grade 11 ★★★★★

Prove that the number of labelled trees on vertices \(1,\ldots,n\) is \(n^{n-2}\).

Details
Problem: COM-B2-M03-P018
Difficulty: Level 5 of 5
Tag: Graphs
Grade: Grade 10, Grade 11
#3.19
#3.19

Catalan Objects

Bijection Grade 10 Grade 11 ★★★★★

Construct a bijection between correct parenthesis sequences with \(n\) pairs of parentheses and triangulations of a convex \((n+2)\)-gon, using the recursive description: the first pair of parentheses determines the triangle adjacent to a fixed side.

Details
Problem: COM-B2-M03-P019
Difficulty: Level 5 of 5
Tag: Bijection
Grade: Grade 10, Grade 11
#3.20
#3.20

General Reflection

Reflection Grade 10 Grade 11 ★★★★★

Let \(a\ge b\). Find the number of paths from \((0,0)\) to \((a,b)\), using \(R,U\), that never go above the diagonal \(y=x\).

Details
Problem: COM-B2-M03-P020
Difficulty: Level 5 of 5
Tag: Reflection
Grade: Grade 10, Grade 11

Ladders

No published ladders were found.
Previous Chapter
Next Chapter