Informal Run-Time Analysis FRQ Practice

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

Question 1 of 5

A timer uses this loop:

int ticks = 0;
for (int h = 1; h <= 8; h++) {
    ticks++;
}

(a) State how many times ticks++ executes. (b) State the new count if the bound is changed to h <= 10. (c) Explain the change by listing which extra h values run the body.

Question 2 of 5

Complete the missing counts for this nested loop.

int count = 0;
for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
        count++;
    }
}
Outer i Times count++ runs this pass Value of count after this pass finishes
1
2
3
4

Then explain why the running total increases by the same amount on every outer pass.

Question 3 of 5

A copier counts inner marks with this structure:

int marks = 0;
for (int i = 1; i <= 5; i++) {
    for (int j = 1; j <= 2; j++) {
        marks++;
    }
}

(a) State how many times marks++ executes. (b) State the new count if the inner bound is changed to j <= 3 and the outer bound is left alone. (c) Explain the increase using completed inner iterations per outer pass.

Question 4 of 5

Compare these two fragments that increment s.

int s = 0;
for (int i = 1; i <= 9; i++) {
    s++;
}
int t = 0;
int i = 1;
while (i <= 9) {
    t++;
    i += 2;
}

(a) State how many times s++ executes and how many times t++ executes. (b) List the values of i that cause the while body to run. (c) Explain why the while fragment runs fewer times by naming the i values that are skipped.

Question 5 of 5

A pattern printer uses an inner bound that depends on the outer variable:

for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
        System.out.print("*");
    }
}

(a) For n = 3, state how many times print("*") executes. (b) For n = 5, state how many times print("*") executes. (c) Explain why the count grows by 9 when n changes from 3 to 5, rather than by 2.