Skip to content

Course home

Representing algorithms

Representing algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
Question 36

An industrial robotics fail-safe system monitors sensor data from two independent channels, representing 4×4 4 \times 4\,4×4 grids of signal levels. Each cell in a grid stores an integer value from 0 to 9.

Two grids are considered mutually stable if:

  • The sum of the signal levels at any corresponding coordinate (r,c)(r, c)(r,c) in both grids is exactly 9.

For example, Sensor B is mutually stable with Sensor A, but Sensor C is not:

Sensor A

Col 0Col 1Col 2Col 3
Row 02751
Row 13486
Row 20924
Row 36153

Sensor B (Mutually Stable with Sensor A)

Col 0Col 1Col 2Col 3
Row 07248
Row 16513
Row 29075
Row 33846

Sensor C (NOT Mutually Stable with Sensor A)

Col 0Col 1Col 2Col 3
Row 07248
Row 16523
Row 29075
Row 33846

(Note: In Sensor C, Row 1, Col 2 has a value of 2, while in Sensor A, Row 1, Col 2 has a value of 8. Their sum is 10, not 9.)

A systems engineer has drafted a pseudo-code algorithm to check if two 4×4 4 \times 4\,4×4 sensor grids, sensorA and sensorB, are mutually stable.

Complete the algorithm in pseudo-code, ensuring that, when the algorithm terminates, the variable isStable is set to true if they are mutually stable, or false otherwise.

The algorithm must work for any valid 4×4 4 \times 4\,4×4 grids stored in sensorA and sensorB. Zero-based indexing is used.

sensorA ← [ [2, 7, 5, 1], [3, 4, 8, 6], [0, 9, 2, 4], [6, 1, 5, 3] ]
sensorB ← [ [7, 2, 4, 8], [6, 5, 1, 3], [9, 0, 7, 5], [3, 8, 4, 6] ]
isStable ← true
r ← 0
WHILE r ≤ 3
    c ← 0
    WHILE c ≤ 3
[6]
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