Maths WorkshopMaths problems with full solutions
Exercise 1696Combinatorics › Graph theoryM1Added 3 Nov 2026

Prüfer sequences

#Prüfer#bijection#labeled trees

Statement

Describe the Prüfer encoding of a labeled tree.

Hint

Repeatedly remove the smallest leaf and record its neighbor.

Show solutionHide solution

Solution

Encoding. Given a tree TT on {1,…,n}\{1,\ldots,n\}:
1. Find the smallest leaf (degree 11).
2. Record its unique neighbor.
3. Remove the leaf.
4. Repeat n−2n-2 times; the sequence of recorded neighbors is the Prüfer sequence.

Decoding. Given a sequence of length n−2n-2, reconstruct the tree.

Bijection. Prüfer sequences of length n−2n-2 over {1,…,n}\{1,\ldots,n\} biject with labeled trees on nn vertices, giving nn−2n^{n-2} trees.

Conclusion. Prüfer sequences give a bijective proof of Cayley's formula.