TAOCP Vol 4A: Combinatorial Algorithms, Part 1 · Week 126
TAOCP 7.1.4 Binary Decision Diagrams (part 2)
Updated
Summary
TAOCP 7.1.4 Binary Decision Diagrams (part 2) covers the rest of 7.1.4 (book pages 233 to 258): most functions have large BDDs, why variable ordering can change sizes exponentially, finding a good order, local swaps and dynamic reordering by sifting (Algorithm J), and more. Budget about 8 hours; do exercises 147, 187 and 198.
Part 2 covers the rest of 7.1.4 (book pages 233 to 258): most functions have large BDDs, why variable ordering can change sizes exponentially, finding a good order, local swaps and dynamic reordering by sifting (Algorithm J), read-once functions, the bad news for multiplication, and zero-suppressed BDDs (ZDDs) with their family algebra, used for exact cover, tilings, word lists, paths in graphs and prime implicants. It ends with a short history and a caveat about when BDDs are the wrong tool.
This week's steps
3 stepsRead §7.1.4 Binary Decision Diagrams (part 2)
Add AND/OR synthesis with a memo cache to your BDD.
Start with Ex 147, Ex 187, Ex 198; 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
This week covers exercises 108 to 267 of the 7.1.4 set (267 in all, rated 05 to M47, 91 recommended); this half has 160 exercises rated 10 to M47, with 55 recommended. Rough map: large BDDs and profiles 108 to 135, variable ordering and reordering 136 to 162, read-once functions and multiplication 163 to 185, ZDD basics 186 to 211, ZDD applications (exact cover, words, paths, cliques, prime implicants) 212 to 267.
Worth your time
Exercise 14727▶ Recommended
Work out the details of swapping two adjacent variables in place. The building block of every dynamic reordering heuristic.
Exercise 18720▶ Recommended
Draw the ZDDs for all 16 functions of two variables and compare with your BDDs.
Exercise 19823▶ Recommended
Write AND for ZDDs. Shows exactly where the different reduction rule changes the algorithm.
Exercise 20816▶ Recommended
Count solutions from a ZDD by modifying the BDD counting algorithm.
Exercise 21225▶ Recommended
Build a ZDD for an exact cover problem. Connects to the dancing links material in Vol 4B.
Exercise 22530▶ Recommended
Build a ZDD of all simple paths between two vertices. This is the idea behind the Simpath algorithm used to count paths on grids.
Exercise 26521▶ Recommended
Find the m-th smallest solution from a BDD. Ranking and unranking, which 7.2.1 uses throughout.
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 14727No 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 164M27No 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 18720No 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 19823No 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 20816No 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 21225No 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 22530No 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 26521No 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
Variable ordering can make a BDD tiny or exponential, a great lesson in representation choice. ZDDs are excellent for combinatorial families and come back in Vol 4B.
Before you start
- 7.1.4 part 1
How to approach it
Add AND/OR synthesis with a memo cache to your BDD. Try two variable orders on the same function and watch the size change.
Common traps
- Assuming a good variable order is easy to find. Finding the best order is expensive in general; heuristics like sifting are what you use in practice.
- Mixing up BDD and ZDD reduction rules. ZDDs remove nodes whose HI branch goes to false, not nodes with equal branches.