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 Expert Approved Answer
Step: 1 Unlock

1 reverseStringString s Java public String reverseStringString s if sisEmpty return Base case empt... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!