Answered step by step
Verified Expert Solution
Question
1 Approved Answer
public static void print(int[] arr) { // Always check for null references first! if (arr null) { } } == } throw new IllegalArgumentException();
public static void print(int[] arr) { // Always check for null references first! if (arr null) { } } == } throw new IllegalArgumentException(); for (int i = 0; i < arr.length; i++) { System.out.println(arr[i]); 1. (5 points) In the appropriate section of ps3_partI (see above), rewrite this method so that it uses recursion instead of iteration. You will need to add a second parameter (call it start) that keeps track of where you are in the array. More precisely, start will specify the start of the portion of the array that the current call is focused on. For example, to print the entire array arr, a client would make the call print(arr, 0). To print the portion of the array that begins at position 3, a client would make the call print(arr, 3). If start is negative, the method should throw an IllegalArgumentException. If start is too big given the length of the array, the method should simply return without printing anything.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Base case If the start index is negative or greater than or equal to the length of the array the method returns without printing anything Recursive ca...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started