2017 CSA FRQ 4B

This question involves reasoning about a two-dimensional (2D) array of integers. You will write two static methods, both of which are in a single enclosing class named Successors (not shown). These methods process a 2D integer array that contains consecutive values. Each of these integers may be in any position in the 2D integer array. For example, the following 2D integer array with 3 rows and 4 columns contains the integers 5 through 16, inclusive. | 0 1 2 3 ------------------ 0 | 15 5 9 10 1 | 12 16 11 6 2 | 14 8 13 7 The following Position class is used to represent positions in the integer array. The notation (r, c) will be used to refer to a Position object with row r and column c. public class Position { /** Constructs a Position object with row r and column c. */ public Position(int r, int c) { / * implementation not shown * / } } Write a static method getSuccessorArray that returns a 2D successor array of positions created from a given 2D integer array. The successor of an integer value is the integer that is one greater than that value. For example, the successor of 8 is 9. A 2D successor array shows the position of the successor of each element in a given 2D integer array. The 2D successor array has the same dimensions as the given 2D integer array. Each element in the 2D successor array is the position (row, column) of the corresponding 2D integer array element's successor. The largest element in the 2D integer array does not have a successor in the 2D integer array, so its corresponding position in the 2D successor array is null. The following diagram shows a 2D integer array and its corresponding 2D successor array. To illustrate the successor relationship, the values 8 and 9 in the 2D integer array are shaded. In the 2D successor array, the shaded element shows that the position of the successor of 8 is ( 0 , 2 ) in the 2D integer array. The largest value in the 2D integer array is 16, so its corresponding element in the 2D successor array is null. Example Array: | 0 1 2 3 ------------------ 0 | 15 5 9 10 1 | 12 16 11 6 2 | 14 8 13 7 Successor Array: | 0 1 2 3 ---------------------------------- 0 | (1,1) (1,3) (0,3) (1,2) 1 | (1,2) null (1,0) (2,3) 2 | (0,0) (0,2) (2,0) (2,1) public static Position[][] getSuccessorArray(int[][] intArr) { USER CODE HERE }