Skip to content

Course home

Representing algorithms

Representing algorithms

EasyMediumHard
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
Question 6

An array represents the status of a sequence of 7 weather sensors along a mountain trail. Each sensor can be either active (A) or idle (I).

Subroutines

SubroutineExplanation
INVERT(n)If the sensor at index nnn is A, it is set to I. If it is I, it is set to A.
COPY_LST(n)The sensor at index nnn is set to the same status as the sensor at index (n−1n - 1n−1).
RESET_RANGE(m, n)All sensors between index mmm and index nnn (but not including mmm and nnn) are set to I.

Initial State

0123456
IAAIAII

What will the array of sensors become after the following algorithm is executed?

p ← 2
INVERT(p + 2)
COPY_LST(p - 1)
INVERT(p + 1)

Write your final answer in the table below:

0123456
[3]
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