{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 19-More Array Algorithms

# Lecture 19-More Array Algorithms - CS1110 4 November 2010...

This preview shows pages 1–2. Sign up to view the full content.

11/3/10 1 CS1110 4 November 2010 Developing array algorithms. Reading: 8.3..8.5 1 Prelim Tuesday, 7:30PM. Olin 155 and 255 Review session, Sunday 1–3. Phillips 101 Handout describes what will be covered. have iclickers ready for quiz Type of d is int [][] (“ int array array”, “an array of int arrays”) To declare variable d: int d[][]. To create a new array and assign it to d: d= new int [3][4]; To reference element at row r column c: d[r][c] number of rows number of cols Two-dimensional arrays 5 4 7 3 b 0 1 2 3 b.length one-dimensional array d 5 4 7 3 4 8 9 7 5 1 2 3 0 1 2 3 0 1 2 rectangular array: 5 rows and 4 columns 2 3 A 2-dimensional array b Same array in row-major order: c P00 P01 P02 P03 P10 P11 P12 P13 P20 P21 P22 P23 You can see that b[0][j] is same as c[0 * (no of columns) + j] b[1][j] is same as c[1 * (no of columns) + j] and in general: b[i][j] is same as c[i * (no of columns) + j] P00 P01 P02 P03 P10 P11 P12 P13 P20 P21 P22 P23 Pixel (picture element): 4 components, each in 0..255 4 Contains: alpha component (we never change it) red component r green component g

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}