TAOCP 7.2.1.1 Exercise 14

No exercise statement is included after “Write the solution now.

Section 7.2.1.1: Generating All n-Tuples

Exercise 14. [20] [20] Design an algorithm to generate all strings a1 . . . aj such that 0 ≤j ≤n and 0 ≤ai < mi for 1 ≤i ≤j, in lexicographic order. For example, if m1 = m2 = n = 2, your algorithm should successively visit ϵ, 0, 00, 01, 1, 10, 11.

Verified: no
Solve time: 6m06s


No exercise statement is included after “Write the solution now.” The text contains the section context for 7.2.1.1, but not the actual problem to solve.

Provide the exact exercise number and statement (e.g., 7.2.1.1.X), and I will produce a full TAOCP-style solution.