Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CSIS 110 Lec. 29: 2D Arrays - Rows & Columns, Lab 23: Finding Max Values - Prof. Brian F. , Study notes of Javascript programming

Information on the organization of 2d arrays in memory, as well as instructions for writing methods to get rows and columns in csis 110. Additionally, there is a lab assignment (lab 23) that requires writing a method to find the maximum value in each row of a 2d array and return it as a one-dimensional array.

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-tf7
koofers-user-tf7 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS 110 - Lecture 29
Quiz: next Wednesday
Last time
2D arrays.
Let's review the memory organization of a 2D array again.
Let's look at TwoDim2 again
- Let's write a method getRow to return the i'th row of the array. Check for i out of
range.
- Let's write a method getColumn to return the i'th column of the array. Check
for i out of range.
Key Points:
- method can return an array.
- method can create an array and return it.
pf2

Partial preview of the text

Download CSIS 110 Lec. 29: 2D Arrays - Rows & Columns, Lab 23: Finding Max Values - Prof. Brian F. and more Study notes Javascript programming in PDF only on Docsity!

CSIS 110 - Lecture 29

Quiz: next Wednesday Last time 2D arrays. Let's review the memory organization of a 2D array again. Let's look at TwoDim2 again

  • Let's write a method getRow to return the i'th row of the array. Check for i out of range.
  • Let's write a method getColumn to return the i'th column of the array. Check for i out of range. Key Points:
  • method can return an array.
  • method can create an array and return it.

Lab 23 Write a method getMaxByRow in class TwoDim2. This method returns a one- dimensional array – the number of elements in the one-dimensional array is the same as the number of rows in the 2D array anArray. The method should set the value of each element of the one-dimensional array to the maximum value in the corresponding row of the 2D array. For example, if the 2D array is: 10 7 19 2 -3 5 0 8 12 4 8 - Then this method should return a one-dimensional array containing 3 elements: 19 8 12 Suggested approach: Write a private method getMax( int[] row ) that returns the maximum value in a row of the two-dimensional array. Recall that each row is a one-dimensional array. Use a for loop to call this method for each row in the 2D array. Store the return value in the appropriate element of a one-dimensional array, and return this array when it is full. Use the homework submission system (link on course web site) to turn in Lab 23.