Showing Page:
1/2
(In Java): Complete the method indexOfMinFromCol(int[][]
a, int c). This method should find and return the index of
the minimum element from column c of the array a. Note
that you want to get the index of the minimum element
(i.e., which row is the minimum in?), rather than the
minimum element itself. COMPLETE THIS METHOD finds
and returns the index of the min element from column c of
the array a public static int indexofMinFromcol (int[][] a,
int c) t return 0;
Solution
public static int indexOfMinFromCol(int[][] a,int c){
int min=0; //initialise minimum index to first element of
column in array
//this loop compares element stored at index min in the
column with every element of column and overwrites min
with that index if it is smaller
for(int i=0;i<a.length;i++){
if(a[i][c]<a[min][c]){
min=i;
}
Showing Page:
2/2
}
return min;
}

### Unformatted Attachment Preview

(In Java): Complete the method indexOfMinFromCol(int[][] a, int c). This method should find and return the index of the minimum element from column c of the array a. Note that you want to get the index of the minimum element (i.e., which row is the minimum in?), rather than the minimum element itself. COMPLETE THIS METHOD finds and returns the index of the min element from column c of the array a public static int indexofMinFromcol (int[][] a, int c) t return 0; Solution public static int indexOfMinFromCol(int[][] a,int c){ int min=0; //initialise minimum index to first element of column in array //this loop compares element stored at index min in the column with every element of column and overwrites min with that index if it is smaller for(int i=0;i
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4