Consider the skeleton code in class ReviewQ3 given below. Complete the methods in order to perform two tasks:
A: Re-order the rows of the 2-d array so that the row sums are in ascending order. You may assume that all rows exist.
B: Re-order the columns so that the column sums are in ascending order. You may assume that all rows exist and that the 2-d array is rectangular.
Use the selection sort algorithm for sorting. For task A, the code you write should not assume that the 2-d array is rectangular.
public class ReviewQ3 {
public static void main(String[] args) {
double[][] x = new double[][]{{45,5,6,4,1,9,4,4},
{2,6,3,4,5,5,6,3},
{2,3,4,5,6,7,8,9}};
printArray(x);
selectSortByRows(x);
printArray(x);
selectSortByCols(x);
printArray(x);
}
/** Print 2-d array x */
public static void printArray(double[][] x) {
}
/** = sum of 1-d array */
public static double rowSum(double[] array) {
}
/** = sum of column j in 2-d array */
public static double colSum(double array[][], int j) {
}
/** Select sort 2-d array such that row sums are in ascending
order */
public static void selectSortByRows(double[][] array){
} //method selectSortByRows
/** Select sort 2-d array such that column sums are in ascending
order */
public static void selectSortByCols(double[][] array){
} //method selectSortByCols
} //class ReviewQ3