TAOCP Vol 4A: Combinatorial Algorithms, Part 1 · Week 131

TAOCP 7.2.1.5 Generating All Set Partitions

Updated

About 6 hours82 exercises, rated 14 to HM46

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.

Flashcards 14 cards for Anki and AnkiMobile · all decks

Anki deck.tsv

This week's steps

3 steps
  1. Read §7.2.1.5 Generating All Set Partitions

    Implement generation via restricted growth strings and verify counts match Bell numbers.

  2. Work the exercises (8 picked)

    Start with Ex 2, Ex 4, Ex 6; log what you solve below.

  3. 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 222▶ Recommended

    Keep linked lists of each block up to date as Algorithm H runs.

    Discuss

  • Exercise 421▶ Recommended

    Classify the SGB five-letter words by their letter-repetition pattern. Restricted growth strings in practice.

    Discuss

  • Exercise 625▶ Recommended

    Generate set partitions with given numbers of blocks of each size.

    Discuss

  • Exercise 1128▶ Recommended

    Count how many set partitions of the digit positions in SEND+MORE=MONEY give pure alphametics.

    Discuss

  • Exercise 26M22▶ Recommended

    Interpret Peirce's triangle as counting paths.

    Discuss

  • Exercise 38M30▶ Recommended

    Study sequences of cyclic shifts whose product is the identity. The stretch.

    Discuss

  • Exercise 65HM22▶ Recommended

    Find the variance of the number of blocks of size k in a random set partition.

    Discuss

  • Exercise 6922▶ Recommended

    Restrict the multiset partition generator to at most r parts.

    Discuss

Your log

Sign in to log the exercises you work: number, rating, how far you got.

Your notes

Only you

Sign 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 posts

Questions 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 ```spoiler block.

    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 ```spoiler block.

    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 ```spoiler block.

    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 ```spoiler block.

    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 ```spoiler block.

    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 ```spoiler block.

    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 ```spoiler block.

    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 ```spoiler block.

    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.

Spot a mistake? Report it

Back to week 131