Complete the trace table for the algorithm shown in Figure 1 when the variable grid is given the following value from the user:
101100
You may not need to use every row in the table.
Figure 1
grid ← USERINPUT
line ← ""
FOR p ← 0 TO LEN(grid) - 1
IF grid[p] = '1' THEN
line ← line + "X"
ELSE
line ← line + "O"
ENDIF
IF p MOD 3 = 2 THEN
line ← ""
ENDIF
ENDFOR
grid | p | line |
|---|---|---|
101100 |