Search Header Logo
Slides8.1_RowMajor_and_ColumnMajor

Slides8.1_RowMajor_and_ColumnMajor

Assessment

Presentation

Computers

11th Grade

Practice Problem

Easy

Created by

Lauren Wheelwright

Used 1+ times

FREE Resource

4 Slides • 4 Questions

1

Multiple Choice

String[][] x = { {"A", "S" }, {"P" ,"C"} };

Which of the following Strings will store "APCSA"?

1

String a = x[0][0] + x[1][0] + x[1][1] + x[0][1] + x[0][0];

2

String b = x[0][0] + x[1][1] + x[0][1] + x[1][0] + x[0][0];

2

Multiple Choice

Print the sum of the four corners of a 3x8 2D array:

int[][] arr = new int[3][8];

1

System.out.println(arr[0][0] + arr[2][0] + arr[2][7] + arr[0][7]);

2

System.out.println(arr[0][0] + arr[3][0] + arr[3][8] + arr[0][8]);

3

Row-major vs Column-Major

int[][] x = {
{1,2,3,4},
{5,6,7,8}
}

​Row-major

​Column-major

​1 2 3 4 5 6 7 8

1 5 2 6 3 7 4 8

4

Multiple Choice

What's the column-major order of the following array?

int[][] x = { {2,4,6}, {8,10,12}, {14,16,18} };

1

2 4 6 8 10 12 14 16 18

2

2 8 14 4 10 16 6 12 18

3

2 10 18 4 8 14 6 12 18

5

Multiple Choice

After the code below executes, what's the row-major order for x?

boolean[][] x = new boolean[3][2];

x[0][1] = true;

x[2][0] = true;

1

false false true true false false

2

false true false false true false

6

Project 8.1 - 8.1.6 Complete Chessboard

You could initialize every element either on its own line or in a loop:
int[][] arr = new int[8][8];
arr[0][0] = "Rook";
...
for (int i = ___; i < ___; i++) {
arr[?][?] = "Pawn";
}

You could initialize the whole 2D array at once:
int[][] arr = { {"Rook", "Knight", ...}, {...}, ... };

OR

7

Project 8.1 - 8.1.7 Tic Tac Toe Board

Initialize a tic-tac-toe board with dashes:
[
["-", "-", "-"],
["-", "-", "-"],
["-", "-", "-"]
]

For each row:
For each column:
arr[row][col] = "-";

8

Matrix operations

media
media

​1

2​

3​

​4

5​

6​

​7

​8

9​

String[][] x = { {"A", "S" }, {"P" ,"C"} };

Which of the following Strings will store "APCSA"?

1

String a = x[0][0] + x[1][0] + x[1][1] + x[0][1] + x[0][0];

2

String b = x[0][0] + x[1][1] + x[0][1] + x[1][0] + x[0][0];

Show answer

Auto Play

Slide 1 / 8

MULTIPLE CHOICE