mkdir ~/cs170/hw11 cp ~cs170002/share/hw11/*.java ~/cs170/hw11 cd ~/cs170/hw11 |
The isPalindrome(s) receives a String typed input parameter s and returns true if s is a palindrome and returns false otherwise.
In this homework, we will write a recursive algorithm to test if a string is a palindrome
|
Example 1:
Input: "abccbx"
Check the first and the last letters:
"abccbx"
Not equal ===> not a palindrome (done)
|
|
|
|
Note: don't just use my test program blindly.... you should look inside my test programs also. They should you how your methods are invoked. Very informative....
Original string: "c0c1c2.....cn-3cn-2cn-1"
Folded string: "c0cn-1c1cn-2c2cn-3....."
|
In this homework, we will write a recursive foldString algorithm
Suppose you want to fold this string:
"c0c1c2.....cn-3cn-2cn-1"
You can solve it as follows:
1. have someone solve this smaller problem:
"c1c2.....cn-3cn-2"
2. using the solution of the above problem, your problem
is solved by pre-pending
c0cn-1
in front of the solution of the above problem.
|
There are 2 base cases that you need to take care of:
|
|
cd ~/cs170/hw11 /home/cs170002/turnin-hw hw11.java hw11 |