Solved

Searching 2d array via Rows

Posted on 2004-09-25
3
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn different types of Android Layout and some basics of an Android App.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

726 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