Question: I need help with writing 3 Recursive methods. Number 1) /** This method displays a given character the specified number of times on one line.

I need help with writing 3 Recursive methods.

Number 1)

/** This method displays a given character the specified number of times on one line. For example, the call displayRowOfChacaters('+', 5); returns "+++++" Implement this method using recursion. @param toShow The character to display. @param n The number of times to display it; n>0. @return String representations of n toShow chars. */

public static String displayRowOfCharacters(char toShow, int n) {

}

Number 2)

/** * Recursively display an array backward starting at position n.

* E.g., displayBackwards(new Integer[]{1,2,3,4}, 2)

* would return "21".

*

* Implement this method using recursion.

*

* @param arr The array to display will have at least two elements.

* @param n The number of entries to be returned; 1<=n<=arr.length.

* @return String value of first n values of arr backwards.

*/

public static String displayBackwards(int[] arr, int n)

{

}

Number 3)

/**

* Recursive method that finds the second smallest object in an array of

* Comparable objects. E.g., getSecondSmallest(new Integer[]{-1,10,3,2},4)

* would return 2.

*

* @param arr An array of Comparable objects; arr.length>=2.

* @param len Length/size of arr array.

* @return Second smallest (Comparable) object in this array.

*/

public static > T getSecondSmallest(T[] arr, int len)

{

}

NOTE: NO DATA FIELDS CAN BE INTRODUCED AND USED and NO IMPORT STATEMENTS ARE ALLOWED

Also NO USAGE OF FULLY-QUALIFIED CLASS NAMES ARE ALLOWED

These three different methods should go in a class called

public final class RecursionProblems{

}

Thank you for your help!

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!