Solved

Searching 2d array via Rows

Posted on 2004-09-25
3
176 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Maven Project: Hibernate Dependencies Conflict 10 38
jsp login check 12 42
eclipse console opening separately 2 29
Java: anonymous class 4 29
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

792 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