Question: Question 4 (15 marks) Recursion: Write a recursive function that will determine if a fully populated array is sorted from largest to smallest returning true


Question 4 (15 marks) Recursion: Write a recursive function that will determine if a fully populated array is sorted from largest to smallest returning true if it is and false otherwise. For example, the following statements would lead to the underlined output: Example 1: int[] ar = {1, 5, 10, 20} System.out.println( isSorted( ar, 0)); false Example 2: int[] ar = {20, 10, 5} System.out.println( is Sorted( ar, 0)); true Example 3: int[] ar = {1} System.out.println( is Sorted( ar, 0 )); true Please write your function on the following page. You may use this page for rough work, but anything on this page will not be graded. int index) public static boolean is Sorted (int[] ar, {
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
