Implementation of an Iterative Function to do Permutation ( Due 14 Nov 2003 )

This programming assignment is a modification of the programming assignment P17.11 on page 700 in your book. Permutation is an important problem. You could be given a set of elements and asked for all the permutations of that set or a subset of all the permutations. There is a recursive algorithm for generating all the permutations but you pay a price in memory usage.

The book also gives an iterative implementation of the permutations of the numbers from 0 to n-1. You can look upon this as the permutation of the indices of the array that has the elements that you were asked to permute. Map the permutation of the array indices with the actual permutation of the elements under consideration.

Study the class NumberPermutationGenerator and make sure that you understand the algorithm. You will use this class as a helper class. In the class that you will write called Permute you will prompt the user to enter a string. You will create a NumberPermutationGenerator object and generate the permutations of the indices for the string. You will write out all the permutations. Test your code with strings of length 3 and 4 since you can easily verify all the permutations.

The file that you will be turning in will be called Permute.java. It will have two classes NumberPermutationGenerator and Permute. The file will have a header as follows:

/*
  File: Permute.java

  Description:

  Student Name:

  Student UT ID:

  Course Name / Unique Number: CS 313E / 52320

  Date Created:

  Date Last Modified:

*/

Use the turnin program to submit the Permute.java file. The TA should receive your work by 11 PM, Friday, 14 November 2003.