Unit 8 - 2D Array Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

2D array

A

An array of arrays
Can be better way to store data
Exp - seating chart of students

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Rectangular 2D array

A

Each row array has same number of elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Declaring a 2D array

A

DataType [ ] [ ] nameOf2DArray

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Initializing a 2D array

A

Needs to know # of rows and columns

new DataType [r] [c]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

If you know what elements of 2D arrrays you want to include, you can

A

initialize the 2D array with a set of initializer lists

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Initializer lists

A

Starts & ends with curly brackets {}
Each row has its own initializer list
Separating elements and initializer lists with commas

{{“Alice”,”Rob”,”Cody”},{“Robin”,”Becky”,”Kisha”}}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

We refer to 2D array’s size by

A
# of rows along with # of columns
r by c
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to determine number of rows in a 2D array

A

r = grades.length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to determine number of column in a 2D array

A

c = grades[0].length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to access an element in a 2D array

A

name of array variable
2 sets of square brackets
index of row where element is located
index of row where element is located

grade [5,2]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to access an element in a 2D array

A

grade [5,2] = grade [5,2] + 1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to create a new 2D array

A

DataType [ ] [ ] nameOf2DArray = new DataType [r][c];

String [ ] [ ] seating = new String [10][3}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In order to print out the contents of a 2D array,

A

you need to use for loops inside of for loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In order to print out the contents of a 2D array, and you don’t know the specific dimensions,

A

you need to use
nameOf2DArray.length for row and
nameOf2DArray [0].length for column

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Nested iteration statements can be written to traverse 2D array in

A

row-major order or column-major order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly