CSC 300
Homework Assignment #8
Spring 2015
Due Date: 3/30/2015

1. Exercise 12, page 413.

2. Exercise 18, page 413.

3. Exercise 26, page 414.

4. Exercise 38, page 414.

5. Exercise 8, page 421.

6.  Write a program that implements the NextPermutation method described in Algorithm 1,page 436.  Be careful with subscripts.  The algorithm assumes that arrays are indexed from 1 to n, but Java and C++, among other languages, start indexing arrays at 0.  Use your program to print out all 24 of the permutations of the integers 1 through 4 in lexicographic order.

7.  Write a program that implements the NextBitString method described in Algorithm 2, page 437.  Be careful with subscripts.  The algorithm assumes that array location 0 is the last entry in the array, rather than the first.  Use your program to print out all 32 subsets of the set {A, B, C, D, E}, according to the discussion at the top of page 437.

8.  Write a program that implements the Next_R_Combination method described in Algorithm 3, page 438.  Be careful with subscripts.  The algorithm assumes that arrays are indexed from 1 to r, but Java and C++, among other languages, start indexing arrays at 0.  Use your program to print out all 20 of the subsets of the set {1, 2, 3, 4, 5, 6} with exactly 3 elements.


Please submit your answers to problems 1 through 5 on notebook paper, one side only, in the correct order. For problems 6, 7,  and 8, print out the source code of your program and the output that it produces when executed. NEATNESS COUNTS!