An automated sorting grid in a pharmaceutical facility manages liquid samples using the subroutines detailed in the table below.
| Subroutine | Purpose |
|---|---|
getVial(row, column) | Returns the ID code of the vial at the given row and column. Returns 0 if the slot is empty. |
transfer(row, column) | Slides the vial at the given row and column into the adjacent empty slot. |
displayTray() | Outputs the final layout of the tray. |
IF getVial(1, 2) == 0 THEN
transfer(2, 2)
ENDIF
IF getVial(2, 2) == 0 THEN
transfer(2, 1)
ENDIF
displayTray()
| column 0 | column 1 | column 2 | |
|---|---|---|---|
| row 0 | 12 | 15 | 18 |
| row 1 | 11 | 14 | |
| row 2 | 13 | 16 | 17 |
Complete the table below to show the final state of the tray after the algorithm has finished running.
| column 0 | column 1 | column 2 | |
|---|---|---|---|
| row 0 | |||
| row 1 | |||
| row 2 |
208 exam-style questions on AQA GCSE Computer Science Representing algorithms. Each one has a worked solution and a mark scheme showing where the marks go.