
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
7 questions
Derechos de Autor - Clase 1
Presentation
•
11th Grade
7 questions
Asesmen awal
Presentation
•
11th Grade
3 questions
Bab 2.1. Proses Pemrograman
Presentation
•
11th Grade
7 questions
Sistema Escalonado
Presentation
•
10th Grade
6 questions
PKWU STRATEGI PROMOSI
Presentation
•
11th Grade
9 questions
materi bab 2 algoritmik dan pemrograman
Presentation
•
11th Grade
5 questions
Браузер
Presentation
•
11th Grade
6 questions
Bài học không cóTRò chơi chữ cái E- Ê tiêu đề
Presentation
•
KG
Popular Resources on Wayground
20 questions
Math Review
Quiz
•
3rd Grade
15 questions
Fast food
Quiz
•
7th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
10 questions
Identify Fractions, Mixed Numbers & Improper Fractions
Quiz
•
3rd - 4th Grade
Discover more resources for Computers
10 questions
Fact Check Ice Breaker: Two truths and a lie
Quiz
•
5th - 12th Grade
10 questions
Video Games
Quiz
•
6th - 12th Grade
15 questions
Memorial Day Trivia
Quiz
•
KG - 12th Grade
12 questions
Name that Candy
Quiz
•
KG - 12th Grade
20 questions
Guess The App
Quiz
•
KG - Professional Dev...
30 questions
K/H Final Review Part 1
Quiz
•
9th - 12th Grade
40 questions
NCFE Earth and Environmental Science Released Test
Quiz
•
9th - 12th Grade
22 questions
Revise and Edit Final Review 3
Quiz
•
8th - 12th Grade