Nested Iteration FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

A library maps aisles to bins with this nested loop:

for (int aisle = 1; aisle <= 2; aisle++) {
    for (int bin = 4; bin <= 6; bin++) {
        System.out.print(aisle);
        System.out.print(bin);
        System.out.print(" ");
    }
}

(a) List the (aisle, bin) pairs in the order the inner body runs. (b) Write the exact text printed, including spaces. (c) Explain why 24 cannot appear before 16.

Question 2 of 5

Complete the missing cells. Then state the full printed text.

for (int r = 1; r <= 4; r++) {
    for (int c = 1; c <= r; c++) {
        System.out.print(c);
    }
    System.out.print(" ");
}
Outer r Inner c values this pass Text printed this pass, including the space
1
2
3
4

Question 3 of 5

Compare these two inner conditions. Both use the same outer loop for (int i = 1; i <= 4; i++).

int left = 0;
for (int i = 1; i <= 4; i++) {
    for (int j = 1; j < i; j++) {
        left++;
    }
}
int right = 0;
for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= i; j++) {
        right++;
    }
}

(a) State the final values of left and right. (b) Explain why left is smaller using inner completion on each outer pass. (c) Identify the outer i value for which the first inner loop does not run at all.

Question 4 of 5

A concession stand needs two rows of three hashes, each row ending with a newline:

###
###

(a) Write nested for loops that produce that pattern. (b) State how many times print("#") runs. (c) State the new print("#") count if the outer loop is changed to run 3 times instead of 2, with the inner bound unchanged.

Question 5 of 5

A ferry log mixes a while outer loop with a for inner loop:

int k = 1;
while (k <= 3) {
    for (int m = 1; m <= k; m++) {
        System.out.print(m);
    }
    System.out.print("-");
    k++;
}

(a) Write the exact text printed. (b) State how many times print(m) runs. (c) Explain why the inner for loop can start at 1 on every outer pass even though m was 2 at the end of the previous pass. (d) Describe the printed text if the inner header were mistakenly written for (int m = k; m <= 3; m++).