Question: Write the following RECURSIVE methods (non-recursive methods will receive no credit!): Remember: the basic process for creating a recursive method is to first determine the
Write the following RECURSIVE methods (non-recursive methods will receive no credit!):
Remember: the basic process for creating a recursive method is to first determine the base case and then build the method.
String reverseString(String s)
This method returns the string with the characters in reverse order. For example:
reverseString("FOX") returns "XOF"
String insertCommas(int num)
This method takes a positive integer parameter and returns a string representing that integer with commas in appropriate places. The method might be called as follows:
System.out.print(insertCommas(1000000)); //prints "1,000,000"
(Hint: recurse by repeated division and build the string by concatenating after each recursive call.)
Previous
Step by Step Solution
3.38 Rating (148 Votes )
There are 3 Steps involved in it
1 reverseStringString s Java public String reverseStringString s if sisEmpty return Base case empt... View full answer
Get step-by-step solutions from verified subject matter experts
