Angie A.

asked • 05/04/20

Need some help with ragged array method I was working on I need some help with explaining method

getHighestInColumnIndex

public static int getHighestInColumnIndex(double[][] data,

int col)

Returns index of the largest element of the selected column in the two dimensional array index 0 refers to the first column. If a

row in the two dimensional array doesn't have this column index, it is not an error, it doesn't participate in this method.

Parameters:

data - the two dimensional array

col - the column index to find the largest element of (0 refers to the first column)

Returns:

the index of the largest element of the column





my code

ublic static int getHighestInColumnIndex(double[][] data, int col) {

double max = data[0][col];

int location = -1;

for(int i =0; i<data.length; i++) {

if(col>= 0 && col<data[i].length) 

if(data[i][col]>max) {

location = i;

}


}


return location;


}





Angie A.

I keep get assertion error
Report

05/04/20

1 Expert Answer

By:

Patrick B. answered • 05/04/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Angie A.

you have to return it as an int
Report

05/04/20

Angie A.

Thats the part I am stuck on return the ragged array location index as a int
Report

05/04/20

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.