
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
5 questions
Administrasi Sistem Jaringan
Presentation
•
11th Grade
5 questions
LA EDUCACIÓN VIRTUAL
Presentation
•
11th Grade
7 questions
Inductive Reasoning
Presentation
•
10th - 11th Grade
6 questions
QUIZ KOMPUTER AKUNTANSI
Presentation
•
12th Grade
6 questions
الوسائط المتعددة
Presentation
•
10th Grade
7 questions
Pengalamatan Jaringan CIDR
Presentation
•
11th Grade
8 questions
HỆ ĐIỀU HÀNH
Presentation
•
11th Grade
10 questions
Introducción al diseño web
Presentation
•
11th Grade
Popular Resources on Wayground
20 questions
STAAR Review Quiz #3
Quiz
•
8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
6 questions
Marshmallow Farm Quiz
Quiz
•
2nd - 5th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
12 questions
What makes Nebraska's government unique?
Quiz
•
4th - 5th Grade
Discover more resources for Computers
20 questions
Grammar
Quiz
•
9th - 12th Grade
31 questions
Easter Trivia
Quiz
•
KG - 12th Grade
16 questions
Circles - Equations, Central & Inscribed Angles
Quiz
•
9th - 12th Grade
46 questions
Unit 4 Geosphere Test Review
Quiz
•
9th - 12th Grade
25 questions
Early Cold War Quizziz
Quiz
•
11th Grade
10 questions
Climate Change and Its Impact
Interactive video
•
9th - 12th Grade
35 questions
Venn Diagrams, Theoretical, & Experimental Review
Quiz
•
9th - 12th Grade
20 questions
Food Chains and Food Webs
Quiz
•
7th - 12th Grade