Lecture 19-More Array Algorithms

Lecture 19-More Array Algorithms - 11/3/10 1 CS1110 4...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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 13. 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 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..255Pixel (picture element): 4 components, each in 0....
View Full Document

Page1 / 2

Lecture 19-More Array Algorithms - 11/3/10 1 CS1110 4...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online