answersLogoWhite

0

// Pseudocode

int findMax( int[][] data ) {

// Return if data is empty

if( data.length 0 ) {

return 0;

}

int max = data[0][0];

// Iterate through each element in the array

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

for( int c = 0; c < data[0].length; ++c ) {

// If we find a value greater than the current max, update max

if( data[r][c] > max ) {

max = data[r][c];

}

}

}

return max;

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

How do you find the average of rows and columns in a 2d array in java?

You add up all the array elements, then divide by the number of elements. You can use a nested for() loop in Java; inside the inner for() loop, you can both increase a counter (to count how many elements there are), and add to a "sum" variable.


Subtraction of 2d array in java?

looda le lo mera


How do you make a BINGO card using Java 3.0 that when you run again the number in the bingo card will not be seen again..it would be in random?

I don't know about Java 3.0 but with the current version of Java 5.0 The Random class could be used or the Math.random() method (which really uses the Random class). The way I would approach this after getting the random number generator down is to make a class to be the Bingo Card, perhaps implemented with an instance of a 2D Array (an Array of Arrays) to hold each number, perhaps a 2D array to hold whether each box is stamped, and a method to check whether I have a bingo. If you have questions about 2D Arrays and how to manipulate them check out the link below.


What is an array to show 4X4?

An array of 4 times 8 is a 2D array with 4 Rows and 8 Columns. // Declaration of a 2D array [ROWS] [COLUMNS] int [][] arr = new int[4][8]; // What a 2D Array looks like populated with numbers // // _____________________ // Row 0 | 1 0 0 0 0 0 0 7 // Row 1 | 0 0 0 0 0 0 0 0 // Row 2 | 0 0 0 0 0 0 4 0 // Row 3 | 0 0 0 0 0 0 0 0 The example array above has the number 1 place in the first row of the first column. In the first row of the eight column the number 7 is placed. In the third row of the seventh column the number 4 is placed. // Accessing these values int one = arr[0][0]; int seven = arr[0][7]; int four = arr[2][6];


Would there be any Memory issues or execution issues or any merits or demerits of using 1D array of size 'mn' instead of using 2D array of size mxn?

It requires the same amount of memory, so it wouldn't spare anything. Don't do it.

Related Questions

Difference between 1D array and 2D arrays?

1d array contains single row and multiple columns and 2d array contains multiple row and multiple columns. 2d array is a collection of 1d array placed one below another,while 1d array is simple a collection of elements.


Flow chart of multiplication of 2d array?

algorithm &amp; flowchrt of 2d matrices


Is there any overhead issues if you make a 2D array arr28 rather than making a 1D array arr16 of size 16 Any memory issues or execution differences between the two?

2D array of size 2x8 and 1D array of size 16


How do you find the average of rows and columns in a 2d array in java?

You add up all the array elements, then divide by the number of elements. You can use a nested for() loop in Java; inside the inner for() loop, you can both increase a counter (to count how many elements there are), and add to a "sum" variable.


Subtraction of 2d array in java?

looda le lo mera


How do you make a BINGO card using Java 3.0 that when you run again the number in the bingo card will not be seen again..it would be in random?

I don't know about Java 3.0 but with the current version of Java 5.0 The Random class could be used or the Math.random() method (which really uses the Random class). The way I would approach this after getting the random number generator down is to make a class to be the Bingo Card, perhaps implemented with an instance of a 2D Array (an Array of Arrays) to hold each number, perhaps a 2D array to hold whether each box is stamped, and a method to check whether I have a bingo. If you have questions about 2D Arrays and how to manipulate them check out the link below.


How do you pass a 2D array in a functions?

if you were to call a function you would write it as: function(array[][], int pretend, double pretend2); arrays will always be passed by reference, not by value.


How do you access 2D array elements by using single variable?

int main() { int array[3][3]; int i; for(i=0; i &lt;9;i++) { printf("the element is %d\n", array[i/3][i%3]); } return 0; }


How many electrons in 2d xy?

The 2d sub energy level does not exist. The first shell to contain a d sub-shell is the third shell: the 3d sub-shell contains a maximum of 10 electrons, with two electrons in each of five different d orbitals.


Can you write a C program to find the sum of a given column in a 2D array?

Use the following function to find the sum of a given column in an array of integers: int sum_column (int** array, unsigned int rows, unsigned int columns, unsigned int column) { assert (column&lt;columns); int accumulator int row; accumulator = 0; for (row=0; row&lt;rows; ++row) { accumulator += array[row][column]; } return accumulator; }


How do you find the volume of a 2D shape?

The answer is zero. A 2D shape has no volume.


What is 8 more than twice a number d?

2d+8