
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lab assignment where students are required to implement a variation of the jumble puzzle code to generate legal variable names for java. The assignment involves creating a class called recursivevariablename and filtering out strings that begin with non-alphabetic characters or end with 'yz'. Students are encouraged to choose between filtering permutations at the beginning or end of the generation process.
Typology: Lab Reports
1 / 1
This page cannot be seen from the preview
Don't miss anything!

224 C. Lab Assignments
You are to implement a variation of the Jumble puzzle code that will recursively generate legal variable names for Java. You should create a class called RecursiveVariableName that will contain the methods. You are free to use wholesale any and all code from the sample code for the Jumble puzzle. The difference between this and the Jumble puzzle is that not all variable names, that is, all permutations of the input, are legal. Your program must filter out the strings generated that would begin with something other than a letter. Further, by convention for this assignment, you should not allow a variable name to end with yz (let us assume that you are working on a project for which these variable names would be reserved for some other part of the project.) Note that there are two possible ways of doing this filtering of permuta- tions. You could wait until the entire permutation is generated and then do the filtering, or you could try to filter out on the fly. In the case of symbols that would start with a non-alpha character, this could be done easily. In the case of symbols that end with yz it is more complicated because you would have to detect in the middle of the permutation code that you had two letters left, y and z, and that you could not choose the y first. In general, filtering at the end means that you may have generated a number of permutations that you throw away, which is wasteful of CPU time. If you filter as soon as possible, then you donāt go down the generation tree for all the recursive calls that would follow a bad choice. You should probably check at the beginning that your first character is alphabetic. On the other hand, a complicated test in the middle of generating the permutations isnāt a good idea unless you know there will be a large chunk of the search tree that is carved away, and since the test for the invalidity of the yz ending is to be done at the very bottom of the recursive tree, itās probably just as easy to wait till the end and throw out the illegally-ending words when you hit bottom. You have several test symbol sets on the Moodle website. The small ones you can do and examine by hand. The longer one will produce a very large number of variable names, so you can perhaps only test on that input by counting the number of legal strings and making sure that you get the correct count.