I'm trying to figure out how to solve this step by step. If someone could explain it without giving just the answer, I would appreciate it.
CSE 142 Section Handout #9 Sample Final Exam 1. Array Mystery
Consider the following method:
public static void mystery(int[] arr) {
if(arr[i-1] < arr[i]) {
arr[i] = arr[i] / 2;
}
}
Indicate in the right-hand column what values would be stored in the array after the method mystery executes if the array in the left-hand column is passed as its parameter.
Original Contents of Array | Final Contents of Array
------------------------- | ----------------------
int[] al = {4, 7}; | mystery(al);
int[] a2 = {3, 16, 5, 10}; | mystery(a2);
int[] a3 = {5, 6, 5, 41}; | mystery(a3);
int[] a4 = {3, 8, 13, 6, 12}; | mystery(a4);
Reference Semantics Mystery
Write the output of the following program below, as it would appear on the console.