K-12 CS Teacher Professional Development Workshop
1.) How many rows and columns does this 2D array have?
int[][] arr = new int[5][8];
5 Rows, 7 Columns
2.) How would one create a diagonal line of 1's across this matrix of zeroes?
0000
0000
0000
0000
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[i].length; j++) {
arr[i][j] = 1;
}
}
3.) What kind of sort involves recursion?
a. Selection Sort
b. Bubble Sort
c. Merge Sort
d. Insertion Sort
A merge sort is the only algorithm which involves recursion.