Solved

Searching 2d array via Rows

Posted on 2004-09-25
3
167 Views
Last Modified: 2010-03-31
The Task:
-----------------------
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
Comment
Question by:smkJackstraw
  • 2
3 Comments
 
LVL 92

Expert Comment

by:objects
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

by:smkJackstraw
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

by:
objects earned 75 total points
ID: 12153387
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
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 …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now