Solved

# Searching 2d array via Rows

Posted on 2004-09-25
167 Views
-----------------------
int findFirstInRow(int rowNum, double value)      Search the specified row for the first occurrence of value.
When you find the first occurrence of value, return the column
number at which it is located.  If you do not find value in
the row, return -1 to indicate this.

The Question:
-----------------------
I've searched arrays before, but have no guidance on 2d arrays and specifying a specific row.  How do I approach breaking this down.  Algorithms plz.
0
Question by:smkJackstraw
• 2

LVL 92

Expert Comment

ID: 12153361
A 2d array is an array of arrays, so get the array for a specific row you would use:

double[][] M = ...;   // the 2-d array
double[] row = M[rowNum];
0

Author Comment

ID: 12153385
Wouldn't the rows and column be integers?  Where as the value in any index be a double.

Would this be specified: double[][] M = M[int rowNum][0];

0

LVL 92

Accepted Solution

objects earned 75 total points
ID: 12153387
0

## Featured Post

### Suggested Solutions

sumHeights2  challenge 7 78
countHi challenge 25 85
strCount chalenge 3 51
how do i compare an object based on two fields 6 34
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …