Question: Hello, I am a but puzzled how to solve a recursive hw problem using arrays. If someone can help solve it so I can break

Hello, I am a but puzzled how to solve a recursive hw problem using arrays. If someone can help solve it so I can break down each line of code step by step I would really appreciate it. Thank you.

Prompt.

Hello, I am a but puzzled how to solve a recursive hw

Recursion2.Java raw code:

/**Three recursive problems.

* Add your code to the four functions given below.

* Do not change any part of the function headers (name, parameters, or return type).

* Do not change any part of the main.

*/

public class Recursion2 {

public static void main( String[] args ) {

int [] array = { 46, 22, 7, 58, 91, 55, 31, 84, 12, 78 };

if( findMax( array ) == 91 ) {

System.out.println( "findMax is correct!" );

}

if( reverseStr( "Hello" ).equals( "olleH" ) ) {

System.out.println( "reverseString1 is correct!" );

}

if( charFrequency( "The quick brown fox jumps over the lazy dog.", 'o' ) == 4 ) {

System.out.println( "charFrequency1 is correct!" );

}

if( findMin( array ) == 7 ) {

System.out.println( "findMin is correct!" );

}

if( reverseStr( "pupils" ).equals( "slipup" ) ) {

System.out.println( "reverseString2 is correct!" );

}

if( charFrequency( "The quick brown fox jumps over the lazy dog.", 'e' ) == 3 ) {

System.out.println( "charFrequency2 is correct!" );

}

}

//Write your facade functions here

/** Finds the maximum value in an array

* @param array array of values (sorted or unsorted)

* @param i iterator

* @param max maximum value found so far

* @return maximum value

*/

public static int maxArray( int [] array, int i, int max ) {

}

/** Finds the maximum value in an array

* @param array array of values (sorted or unsorted)

* @param i iterator

* @param max maximum value found so far

* @return maximum value

*/

public static int minArray( int [] array, int i, int min ) {

}

/** Reverses a string

* @param s the string to reverse

* @return the reversed string

*/

public static String reverseStr( String s ) {

}

/** Returns the number of times c appears in the string str

* @param str string to test

* @param c character to find

* @return number of times the character appeared in the string

*/

public static int charFrequency( String str, char c ) {

}

}

On Beachboard is a skeleton program named: "Recursion2.java". It has a main that performs six tests on three functions. Write the methods described below in order to pass these tests Find Max: Write a recursive function that passes in an array, then finds and returns the maximum value in an array. Create a faade function findMax) to call function maxArray0 Find Min: Write a recursive function that passes in an array, then finds and returns the minimum value in an array. Create a faade function findMin) to call function minArrayO Reverse String: Write a recursive function that passes in a string, and then returns a reversed version of that string Character Frequency: Write a recursive function that passes in a string and a character, then returns the number of times the character appears in a string Hint: Use the String functions given in Supplemental Lecture 1B Notes: 1. Do not modify the main method or any of the function headers. Only add your code to the functions Add your name and date to the Javadoc comment at the top of the program Add brief comments to your functions that describe your code Make sure that your functions are actually recursive. They should not be using while or for loops, only a recursive call. Your program should not take in any user input, it should only run the tests. You should not have any global variables in your program. The parameters and return values can be used to store information between iterations of your recursive functions Test your program before demoing. It should pass all six tests 2. 3. 4. 5. 6. 7

Step by Step Solution

There are 3 Steps involved in it

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