Question: Suppose that we have declared an array as follows: int[] ari = {23, 47, 12, 18, 56}; Consider the call minAr(ari, 0,4) to the recursive
Suppose that we have declared an array as follows: int[] ari = {23, 47, 12, 18, 56}; Consider the call minAr(ari, 0,4) to the recursive function defined below. A) What will be in the most recent stack frame just before the function gets to the base case for the last time. B) Give a tracing tree for the call minarlar1, 0,4). Show each recursive call, its parents and children, and the value it returns. public static int minAr(int[] a, int start, int end){ if (start end){ return a[start]; } else { int middle = (start + end)/2; return Math.min(minAr(a, start, middle), minArca, middle + 1, end)); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
