TAOCP Vol 4A: Combinatorial Algorithms, Part 1 · Week 131
TAOCP 7.2.1.5 Generating All Set Partitions
Updated
Summary
TAOCP 7.2.1.5 Generating All Set Partitions: Generating all partitions of a set: restricted growth strings and Algorithm H, Gray codes for set partitions, Bell numbers and Peirce's triangle, the asymptotics of Bell numbers, Stirling numbers of the second kind, and more. Budget about 6 hours; do exercises 2, 4 and 6.
Generating all partitions of a set: restricted growth strings and Algorithm H, Gray codes for set partitions, Bell numbers and Peirce's triangle, the asymptotics of Bell numbers, Stirling numbers of the second kind, and partitions of a multiset (Algorithm M), with applications to rhyme schemes and alphametics.
This week's steps
3 stepsRead §7.2.1.5 Generating All Set Partitions
Implement generation via restricted growth strings and verify counts match Bell numbers.
Start with Ex 2, Ex 4, Ex 6; log what you solve below.
Write down one thing you'd explain to someone
A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.
Sign in to track this: tick each step off and it counts toward your week.
Exercises
Section 7.2.1.5 has 82 exercises, rated 14 to HM46, and Knuth marks 19 of them with the triangle for recommended. Algorithms and Gray codes 1 to 25, Peirce's triangle and combinatorics 26 to 44, asymptotics 45 to 68, multiset partitions 69 to 82.
Worth your time
Exercise 421▶ Recommended
Classify the SGB five-letter words by their letter-repetition pattern. Restricted growth strings in practice.
Exercise 1128▶ Recommended
Count how many set partitions of the digit positions in SEND+MORE=MONEY give pure alphametics.
Exercise 38M30▶ Recommended
Study sequences of cyclic shifts whose product is the identity. The stretch.
Exercise 65HM22▶ Recommended
Find the variance of the number of blocks of size k in a random set partition.
Your log
Sign in to log the exercises you work: number, rating, how far you got.
Your notes
Only youSign in to keep private notes on this guide, in Markdown. They stay yours: never on your profile, and you can export them all.
Discussion
0 postsQuestions about the reading go here; each exercise has its own thread below. Hints over answers.
No posts yet. Ask a question or share a tip.
Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise threads
One thread per exercise. Open one to ask for a nudge or check your thinking.
Exercise 222No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 421No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 625No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 1128No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 26M22No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 38M30No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 65HM22No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Exercise 6922No posts yet
Hints over answers. Say what you tried; put an answer or a full solution inside a spoiler:
||like this||or a```spoilerblock.Sign in to postAnyone can read. Posting needs an account with a confirmed email.
Reference
Why it matters
Set partitions show up in clustering, test case generation and some scheduling problems.
Before you start
- 7.2.1.4 Generating All Partitions
How to approach it
Implement generation via restricted growth strings and verify counts match Bell numbers.