
Slides8.1_RowMajor_and_ColumnMajor
Presentation
•
Computers
•
11th Grade
•
Practice Problem
•
Easy
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"?
String a = x[0][0] + x[1][0] + x[1][1] + x[0][1] + x[0][0];
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];
System.out.println(arr[0][0] + arr[2][0] + arr[2][7] + arr[0][7]);
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} };
2 4 6 8 10 12 14 16 18
2 8 14 4 10 16 6 12 18
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;
false false true true false false
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
1 | 2 | 3 |
|---|---|---|
4 | 5 | 6 |
7 | 8 | 9 |
String[][] x = { {"A", "S" }, {"P" ,"C"} };
Which of the following Strings will store "APCSA"?
String a = x[0][0] + x[1][0] + x[1][1] + x[0][1] + x[0][0];
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
Similar Resources on Wayground
6 questions
Gmail
Presentation
•
11th Grade
7 questions
cycle 2
Presentation
•
11th - 12th Grade
7 questions
admin infra. jaringan
Presentation
•
11th Grade
8 questions
Soal Array - Informatika
Presentation
•
11th Grade
4 questions
SPREADSHEET
Presentation
•
11th Grade
8 questions
PSEDUCODE
Presentation
•
10th Grade
6 questions
MAC 2 | Lesson 5-7 | Wrap it Up
Presentation
•
KG
6 questions
Dampak sosial Teknologi
Presentation
•
11th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade