|
Bill Teter email: william.teter@plattsburgh.edu |
|
|
Project 2 -- Permutations with recursion Write a class called Permute that implements Iterable. The constructor for the class will have a String parameter. The Iterator returned by the iterator() method will have a next method that returns a String which is a permutation of the characters in the original String passed to the Permute constructor. The hasNext() method will continue to be true until all the permutations have been returned. Make the remove() method null. Write a Test program that accepts a single command line argument that contains the characters to be permuted. A loop will then print all the permutations. Estimate the time and space complexity of your solution in terms of n = number of characters to be permuted. Justify your estimates. Make your solution efficient in terms of space and time used. Your program should run with strings of length 20 or more. Lists of characters are not the only object one might wish to permute. Generalize your program so that the constructor for Permute will take as its parameter any list of objects and provide an iterator that will have next() cycle through all the permutations of that list of objects. Write a test program that uses any number of strings as command line arguments as the list of objects to be permuted. I've placed the sample programs that relate to this project in my public account /home/teterwa/public/csc321/proj2 |