Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1FOR Row ← 1 TO 3 FOR Col ← 1 TO 4 | AGrid[Row, Col] ← Row * Col | |
| 2Row = 2 | Col = 1, 2, 3 | BThe loops make 3 x 4 = 12 passes. Row stays fixed while Col runs 1 to 4, so the trace table needs 12 rows. | |
| 3A trace table has a column for the element changed, so the student records which array cell is written on each pass | CThe total passes were added instead of multiplied. It should be 2 x 3 = 6 passes, so the trace table needs 6 lines. | |
| 4The order elements are visited: the outer loop moves down the rows, and the inner loop moves across the columns of each row | DFOR Row ← 1 TO 2 FOR Col ← 1 TO 3 | |
| 5Row 1, Col 1 then Row 2, Col 1 then Row 3, Col 1 | EA trace table shows the outer variable fixed at 2 while the inner variable runs through all of its values. | |
| 62 rows x 3 columns = 5 passes | FThe trace table changes Row on every pass. The outer variable should stay fixed while Col runs through all its values before Row changes. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
trace table — Tracks Row, Column and the element changed. The outer loop variable stays fixed while the inner one runs through all its values. Total passes = rows x columns.FOR Row ← 1 TO 2
FOR Column ← 1 TO 3
Grid[Row, Column] ← Row + ColumnRows ← 2
Columns ← 3
Passes ← Rows * ColumnsFOR Row ← 1 TO 2
FOR Column ← 1 TO 3
Grid[Row, Column] ← 0FOR Row ← 1 TO 2
FOR Column ← 1 TO 3
// Last element visited: Grid[2, 3] Grid[Row, Column] ← 0
NEXT Column
NEXT Row