For your sixth lab, you will play around some more with
recursion. You will
need to write the following recursive functions
- Implement and test a method that uses tail recursion that takes
as input a string and returns a version of the string with all the
characters converted to uppercase. You will likely need to write
a "wrapper" function that calls your tail-recursive function with an
extra parameter (the solution being created). Use
Character.toUpperCase to convert individual characters.
- Design and implement a recursive program to produce the following
output:
0
0 1
0 1 2
0 1 2 3
0 1 2 3 4
0 1 2 3
0 1 2
0 1
0
Your program should prompt the user for the total number of rows she
wishes to print. Your program should use no loops at all, only
recursion.
Hint 1: You may wish to have two recursive functions ...
Hint 2: For one of these functions, you may want to count up to n,
instead of down to zero ...
- Design
and implement a recursive program to print all permutations of a given
string. For instance, given the string "hat" your program should print
the strings "hat", "hta", "aht", "ath", "tha", and "tah".
The order that you print out the permuations does not matter.
Hint 1: This is a backtracking problem ...
Hint 2: First, print all permutations that start with the first
letter, then print all permutations that start with the second letter,
and so on
Hint 3: You may want to have an index that counts up ...
Grading
This lab is pretty simple, and the grading is as well:
- ToUpperCase 20
points
- printVertical
40 points
- Permutations 40
points
Submission
All file(s) required for
your project should be in the folder
https://www.cs.usfca.edu/svn/<username>/cs112/Lab6/