Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

consider following method mystery3: public static void mystery3[int[] data, int

ID: 3609665 • Letter: C

Question

consider following method mystery3: public static void mystery3[int[] data, int x, int y] {    data[data[x]] = data[y];    data[y] = x; } What are the values of the elements in the array numbers afterthe following code executes? int[] numbers = {3,7,1,0,25,4,18,-1,5}; mystery3(numbers, 3, 1); mystery3(numbers, 5, 6); mystery3(numbers, 8, 4); I KNOW THE ANSWER IS{7,3,1,0,8,18,5,-1,5}          I DO NOTKNOW HOW TO GET TO THE FINAL ANSWER IN RED. PLEASE SHOW ME HOW TOGET TO THE FINAL ANSWER FOR A LIFESAVER consider following method mystery3: public static void mystery3[int[] data, int x, int y] {    data[data[x]] = data[y];    data[y] = x; } What are the values of the elements in the array numbers afterthe following code executes? int[] numbers = {3,7,1,0,25,4,18,-1,5}; mystery3(numbers, 3, 1); mystery3(numbers, 5, 6); mystery3(numbers, 8, 4); I KNOW THE ANSWER IS{7,3,1,0,8,18,5,-1,5}          I DO NOTKNOW HOW TO GET TO THE FINAL ANSWER IN RED. PLEASE SHOW ME HOW TOGET TO THE FINAL ANSWER FOR A LIFESAVER          I DO NOTKNOW HOW TO GET TO THE FINAL ANSWER IN RED. PLEASE SHOW ME HOW TOGET TO THE FINAL ANSWER FOR A LIFESAVER

Explanation / Answer

public static void mystery2(int[] a, int[]b) {    for (int i = 0; i<a.length;i++){                                does the loop for as many elements of athere are
      a[i] =a[ 2* i % a.length] -b[3*i%b.length];        only 1st array (a1changes)     do the math and you get thefollowing indices
} What are the values of the elements in array a1 after thefollowing code executes? int[] a1 = {2,4,6,8,10,12,14,16); int[] a2 = {1,1,2,3,5,8,13,21); mystery2(a1,a2) What are the values of the elements in array a1 after thefollowing code executes? int[] a1 = {2,4,6,8,10,12,14,16); int[] a2 = {1,1,2,3,5,8,13,21); mystery2(a1,a2)