Skip to content

Course home

Representing algorithms

Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
Question 63

An automated sorting grid in a pharmaceutical facility manages liquid samples using the subroutines detailed in the table below.

Subroutines

SubroutinePurpose
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.

Algorithm

IF getVial(1, 2) == 0 THEN
    transfer(2, 2)
ENDIF
IF getVial(2, 2) == 0 THEN
    transfer(2, 1)
ENDIF
displayTray()

Initial Tray Layout

column 0column 1column 2
row 0121518
row 11114
row 2131617

Complete the table below to show the final state of the tray after the algorithm has finished running.

column 0column 1column 2
row 0
row 1
row 2
[2]
Markscheme

Representing algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Representing algorithms

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.

Question bank