Question
** IN JAVA** I am currently attempting to write a method with the header public int findFirstRow(int[][] matrix) this method will receive a 2D array(matrix)
** IN JAVA**
I am currently attempting to write a method with the header
public int findFirstRow(int[][] matrix)
this method will receive a 2D array(matrix) where all the entries are either 1 or 0
the method will then return the index of the row that contains the greatest number of 1's
I need the pseudo code for this as well as the overall idea of how this is done.
What I have tried so far....
did two nested for loops i and j that traverse the 2d array and when an element [i][j]==0, then oneCounter++;
the problem with this was that the nested for loops would traverse the entire 2d array and oneCounter would return
the total number of 1's in the entire array.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started