AQA AS-Level · Thinka-original Practice Paper

2022 AQA AS-Level Computer Science 7516 Practice Paper with Answers

Thinka Jun 2022 AQA AS Level-Style Mock — Computer Science 7516

150 marks195 mins2022
An original Thinka practice paper modelled on the structure and difficulty of the Jun 2022 AQA AS Level Computer Science 7516 paper. Not affiliated with or reproduced from AQA.

Section A (Paper 1)

Complete trace tables, label state transition diagrams, and write a program matching the pseudo-code logic.
5 Question · 25 marks
Question 1 · structured
5 marks
The subroutine Mystery is defined below in pseudocode:

SUBROUTINE Mystery(A, B)
X <- A
Y <- B
Z <- 0
WHILE X > 0
IF X MOD 2 = 1 THEN
Z <- Z + Y
ENDIF
X <- X DIV 2
Y <- Y * 2
ENDWHILE
RETURN Z
ENDSUBROUTINE

Part (a) (4 marks):
Complete the trace table below for the execution of Mystery(11, 5).

Note:
- The row for the initial values before entering the loop has been completed for you.
- For each subsequent row, record the values of the variables at the end of each iteration of the WHILE loop.
- If a variable's value does not change during an iteration, leave its cell blank.

IterationXYZInitial11501234

Part (b) (1 mark):
What is the final value returned by the call Mystery(11, 5)?
Show answer & marking scheme

Worked solution

Solution

Part (a):
We trace the execution of the subroutine Mystery(11, 5) step-by-step:
  • Initial state: X = 11, Y = 5, Z = 0.
  • Iteration 1: X > 0 (11 > 0) is true. X MOD 2 = 1 (11 MOD 2 = 1) is true, so Z = 0 + 5 = 5. Then X = 11 DIV 2 = 5 and Y = 5 * 2 = 10.
  • Iteration 2: X > 0 (5 > 0) is true. X MOD 2 = 1 (5 MOD 2 = 1) is true, so Z = 5 + 10 = 15. Then X = 5 DIV 2 = 2 and Y = 10 * 2 = 20.
  • Iteration 3: X > 0 (2 > 0) is true. X MOD 2 = 1 (2 MOD 2 = 0) is false, so Z remains 15 (cell left blank). Then X = 2 DIV 2 = 1 and Y = 20 * 2 = 40.
  • Iteration 4: X > 0 (1 > 0) is true. X MOD 2 = 1 (1 MOD 2 = 1) is true, so Z = 15 + 40 = 55. Then X = 1 DIV 2 = 0 and Y = 40 * 2 = 80.
  • Termination: X > 0 (0 > 0) is false. Loop terminates.

Part (b):
The subroutine returns Z, which has a final value of 55.

Marking scheme

Part (a) (4 marks):
- 1 mark: Row 1 completed correctly (X = 5, Y = 10, Z = 5)
- 1 mark: Row 2 completed correctly (X = 2, Y = 20, Z = 15)
- 1 mark: Row 3 completed correctly (X = 1, Y = 40, Z left blank or written as 15)
- 1 mark: Row 4 completed correctly (X = 0, Y = 80, Z = 55)

Note: Allow follow-through (FT) marks if an arithmetic mistake is carried forward consistently.

Part (b) (1 mark):
- 1 mark: 55 (Accept follow-through from the final value of Z in the trace table).
Question 2 · structured
5 marks
The subroutine Mystery is defined below in pseudocode:

SUBROUTINE Mystery(A, B)
X <- A
Y <- B
Z <- 0
WHILE X > 0
IF X MOD 2 = 1 THEN
Z <- Z + Y
ENDIF
X <- X DIV 2
Y <- Y * 2
ENDWHILE
RETURN Z
ENDSUBROUTINE

Part (a) (4 marks):
Complete the trace table below for the execution of Mystery(11, 5).

Note:
- The row for the initial values before entering the loop has been completed for you.
- For each subsequent row, record the values of the variables at the end of each iteration of the WHILE loop.
- If a variable's value does not change during an iteration, leave its cell blank.

IterationXYZInitial11501234

Part (b) (1 mark):
What is the final value returned by the call Mystery(11, 5)?
Show answer & marking scheme

Worked solution

Solution

Part (a):
We trace the execution of the subroutine Mystery(11, 5) step-by-step:
  • Initial state: X = 11, Y = 5, Z = 0.
  • Iteration 1: X > 0 (11 > 0) is true. X MOD 2 = 1 (11 MOD 2 = 1) is true, so Z = 0 + 5 = 5. Then X = 11 DIV 2 = 5 and Y = 5 * 2 = 10.
  • Iteration 2: X > 0 (5 > 0) is true. X MOD 2 = 1 (5 MOD 2 = 1) is true, so Z = 5 + 10 = 15. Then X = 5 DIV 2 = 2 and Y = 10 * 2 = 20.
  • Iteration 3: X > 0 (2 > 0) is true. X MOD 2 = 1 (2 MOD 2 = 0) is false, so Z remains 15 (cell left blank). Then X = 2 DIV 2 = 1 and Y = 20 * 2 = 40.
  • Iteration 4: X > 0 (1 > 0) is true. X MOD 2 = 1 (1 MOD 2 = 1) is true, so Z = 15 + 40 = 55. Then X = 1 DIV 2 = 0 and Y = 40 * 2 = 80.
  • Termination: X > 0 (0 > 0) is false. Loop terminates.

Part (b):
The subroutine returns Z, which has a final value of 55.

Marking scheme

Part (a) (4 marks):
- 1 mark: Row 1 completed correctly (X = 5, Y = 10, Z = 5)
- 1 mark: Row 2 completed correctly (X = 2, Y = 20, Z = 15)
- 1 mark: Row 3 completed correctly (X = 1, Y = 40, Z left blank or written as 15)
- 1 mark: Row 4 completed correctly (X = 0, Y = 80, Z = 55)

Note: Allow follow-through (FT) marks if an arithmetic mistake is carried forward consistently.

Part (b) (1 mark):
- 1 mark: 55 (Accept follow-through from the final value of Z in the trace table).
Question 3 · Diagram Completion
6 marks
An incomplete state transition diagram for a Mealy finite state machine (FSM) is described below. The machine is designed to process a stream of binary inputs and output a '1' whenever the sequence '110' is successfully detected, and '0' at all other times.

The states are defined as:
- S0: No part of the target sequence has been matched (this is also the start state).
- S1: The sequence '1' has been matched.
- S2: The sequence '11' has been matched.

The transitions between states are labeled with the format input/output (for example, 0/0).

Complete the state transition diagram by identifying the labels for the following six transitions:
1. Transition from S0 to S0: [A]
2. Transition from S0 to S1: [B]
3. Transition from S1 to S0: [C]
4. Transition from S1 to S2: [D]
5. Transition from S2 to S0: [E]
6. Transition from S2 to S2: [F]
Show answer & marking scheme

Worked solution

To find the correct transitions, we analyze the sequence '110' detection logic step-by-step for a Mealy FSM:

1. State S0: We have no active progress on '110'.
- If input is 0, we remain in S0 and output 0. Thus, [A] is 0/0.
- If input is 1, we progress to S1 (first digit matched) and output 0. Thus, [B] is 1/0.

2. State S1: We have matched '1'.
- If input is 0, the sequence is broken, so we go back to S0 and output 0. Thus, [C] is 0/0.
- If input is 1, we progress to S2 (we now have '11' matched) and output 0. Thus, [D] is 1/0.

3. State S2: We have matched '11'.
- If input is 0, the sequence '110' is fully matched. We output 1 and return to S0. Thus, [E] is 0/1.
- If input is 1, we still have '11' at the end of the stream (as '111' ends with '11'), so we remain in S2 and output 0. Thus, [F] is 1/0.

Marking scheme

Award 1 mark for each correct transition label identified:
- [A]: 0/0 (1 mark)
- [B]: 1/0 (1 mark)
- [C]: 0/0 (1 mark)
- [D]: 1/0 (1 mark)
- [E]: 0/1 (1 mark)
- [F]: 1/0 (1 mark)
Question 4 · Programming Implementation
4.5 marks
A programmer is designing a security module. Write a program function in a high-level programming language of your choice that implements the logic of the following pseudo-code algorithm. The algorithm validates whether a serial number string consists of exactly two uppercase English alphabetic characters followed by exactly three numeric digits.

```
SUBROUTINE IsValidSerial(Serial)
IF LEN(Serial) ≠ 5 THEN
RETURN False
ENDIF
FOR I ← 0 TO 1
Char ← Serial[I]
IF NOT (Char ≥ 'A' AND Char ≤ 'Z') THEN
RETURN False
ENDIF
ENDFOR
FOR I ← 2 TO 4
Char ← Serial[I]
IF NOT (Char ≥ '0' AND Char ≤ '9') THEN
RETURN False
ENDIF
ENDFOR
RETURN True
ENDSUBROUTINE
```

Ensure your implemented code matches this logic as closely as possible.
Show answer & marking scheme

Worked solution

Here are standard implementations of the given algorithm in Python, C#, and VB.NET:

### Python
```python
def IsValidSerial(serial):
if len(serial) != 5:
return False
for i in range(0, 2):
char = serial[i]
if not ('A' <= char <= 'Z'):
return False
for i in range(2, 5):
char = serial[i]
if not ('0' <= char <= '9'):
return False
return True
```

### C#
```csharp
public static bool IsValidSerial(string serial) {
if (serial.Length != 5) {
return false;
}
for (int i = 0; i <= 1; i++) {
char c = serial[i];
if (!(c >= 'A' && c <= 'Z')) {
return false;
}
}
for (int i = 2; i <= 4; i++) {
char c = serial[i];
if (!(c >= '0' && c <= '9')) {
return false;
}
}
return true;
}
```

### VB.NET
```vbnet
Function IsValidSerial(Serial As String) As Boolean
If Serial.Length <> 5 Then
Return False
End If
For I As Integer = 0 To 1
Dim CharVar As Char = Serial(I)
If Not (CharVar >= "A"c AndAlso CharVar <= "Z"c) Then
Return False
End If
Next
For I As Integer = 2 To 4
Dim CharVar As Char = Serial(I)
If Not (CharVar >= "0"c AndAlso CharVar <= "9"c) Then
Return False
End If
Next
Return True
End Function
```

Marking scheme

- **1 mark**: Correct function/method definition header with string parameter and correct overall return type framework.
- **1 mark**: Correct validation check on string length (rejecting any string whose length is not exactly 5).
- **1 mark**: Correct loop logic checking that elements at index 0 and 1 represent uppercase alphabetic characters (with standard ASCII bounds/comparison or equivalent functions).
- **1 mark**: Correct loop logic checking that elements at index 2, 3, and 4 represent standard numerical digits (with standard bounds/comparison or equivalent functions).
- **0.5 marks**: Returns true if and only if all preceding constraints are fully met.
Question 5 · Programming Implementation
4.5 marks
An algorithm processes a 1-dimensional integer array `NumList` of size 4. Complete the trace table below for the execution of this algorithm.

```
NumList ← [4, 7, 12, 5]
X ← 0
Y ← 1
WHILE X < 3
IF NumList[X] MOD 2 = 0 THEN
NumList[X] ← NumList[X] DIV 2
Y ← Y * NumList[X]
ELSE
NumList[X] ← NumList[X] + 1
Y ← Y + NumList[X]
ENDIF
X ← X + 1
ENDWHILE
```

Copy and complete the trace table below:

| X | Y | NumList[0] | NumList[1] | NumList[2] | NumList[3] |
|---|---|------------|------------|------------|------------|
| | | 4 | 7 | 12 | 5 |
| | | | | | |
Show answer & marking scheme

Worked solution

Let's perform a step-by-step trace of the execution:

1. **Initialization**:
- `NumList` starts as `[4, 7, 12, 5]`.
- `X` starts at `0`.
- `Y` starts at `1`.

2. **Iteration 1 (`X = 0`)**:
- Condition `X < 3` (‎`0 < 3`‎) is true.
- `NumList[0]` is `4`.
- `4 MOD 2 = 0` is true, so the `THEN` block executes:
- `NumList[0] ← 4 DIV 2` (which is `2`).
- `Y ← 1 * 2` (which is `2`).
- `X ← X + 1` sets `X` to `1`.

3. **Iteration 2 (`X = 1`)**:
- Condition `X < 3` (‎`1 < 3`‎) is true.
- `NumList[1]` is `7`.
- `7 MOD 2 = 0` is false, so the `ELSE` block executes:
- `NumList[1] ← 7 + 1` (which is `8`).
- `Y ← 2 + 8` (which is `10`).
- `X ← X + 1` sets `X` to `2`.

4. **Iteration 3 (`X = 2`)**:
- Condition `X < 3` (‎`2 < 3`‎) is true.
- `NumList[2]` is `12`.
- `12 MOD 2 = 0` is true, so the `THEN` block executes:
- `NumList[2] ← 12 DIV 2` (which is `6`).
- `Y ← 10 * 6` (which is `60`).
- `X ← X + 1` sets `X` to `3`.

5. **Termination**:
- Condition `X < 3` (‎`3 < 3`‎) is false. The loop terminates.
- `NumList[3]` remains unaltered at `5` throughout.

**Completed Trace Table**:

| X | Y | NumList[0] | NumList[1] | NumList[2] | NumList[3] |
|---|---|------------|------------|------------|------------|
| | | 4 | 7 | 12 | 5 |
| 0 | 1 | | | | |
| | 2 | 2 | | | |
| 1 | | | | | |
| | 10| | 8 | | |
| 2 | | | | | |
| | 60| | | 6 | |
| 3 | | | | | |

Marking scheme

- **1 mark**: Correctly traces the first iteration (`X = 0` updates `NumList[0]` to `2` and `Y` to `2`).
- **1.5 marks**: Correctly traces the second iteration (`X = 1` updates `NumList[1]` to `8` and `Y` to `10`).
- **1.5 marks**: Correctly traces the third iteration (`X = 2` updates `NumList[2]` to `6` and `Y` to `60`).
- **0.5 marks**: Correct final value of `X` set to `3` indicating the loop termination condition, with `NumList[3]` correctly left unchanged.

Section B (Paper 1)

Analyse the skeleton program code without running or active coding; trace logic variables and outline structure.
11 Question · 19.800000000000004 marks
Question 1 · short-answer
1.8 marks
Analyse the skeleton program structure where a player explores a grid. The player's position is tracked via integer coordinates. Identify the most appropriate variable identifier and data type to represent the player's current horizontal position (column index) in a 0-indexed 2D grid of size 15 x 15.
Show answer & marking scheme

Worked solution

To represent the current column position, an identifier such as PlayerCol or CurrentColumn is standard. Because array indices in a grid are whole numbers (0 to 14), the appropriate basic data type is an Integer.

Marking scheme

1 mark: Suggesting a sensible integer-focused identifier (e.g., PlayerCol, Col, XCoord, CurrentCol). 0.8 marks: Explicitly specifying the data type as Integer (or int).
Question 2 · short-answer
1.8 marks
In the skeleton program, the grid has dimensions 10 x 10 with indices ranging from 0 to 9. The northernmost row is row 0 and the southernmost row is row 9. Write a Boolean expression used in a subroutine CheckValidMove to verify that a move to the North (which decrements the current row by 1) is valid, given the current row variable is CurrentRow.
Show answer & marking scheme

Worked solution

Moving north decrements the row index. If CurrentRow is 0, moving north would result in an index of -1, which is out of bounds. Thus, the move is only valid if CurrentRow - 1 >= 0 or equivalently CurrentRow > 0.

Marking scheme

1.8 marks for either CurrentRow > 0 or CurrentRow - 1 >= 0 (or equivalent boolean logic).
Question 3 · short-answer
1.8 marks
The skeleton program contains a procedure GenerateTreasure(NumTreasure) to distribute treasure items randomly across an 8 x 8 grid. If NumTreasure is set to 3, and the random number generator generates the coordinate pairs in this sequence: (2, 3), (2, 3), (5, 6), (7, 1). Assuming the procedure checks if a cell is already occupied before placing a treasure (and does not decrement the remaining count unless placement is successful), state the total number of treasure items successfully placed on the grid and identify which coordinate is the duplicate.
Show answer & marking scheme

Worked solution

The generator generates (2, 3) which is empty, so treasure 1 is placed at (2, 3). The second coordinate pair is (2, 3), which is already occupied. The procedure skips this and does not place treasure 2 here. The third is (5, 6), which is empty, so treasure 2 is placed at (5, 6). The fourth is (7, 1), which is empty, so treasure 3 is placed at (7, 1). Thus, 3 items are successfully placed. The duplicate coordinate is (2, 3).

Marking scheme

1 mark for stating that 3 items are placed. 0.8 marks for identifying (2, 3) as the duplicate coordinate.
Question 4 · short-answer
1.8 marks
In the skeleton program, the grid variable Grid is declared as a local variable inside the Main procedure. To allow another procedure, UpdateGrid, to modify the grid and have these modifications reflected back in the Main procedure, state the parameter-passing mechanism that must be used.
Show answer & marking scheme

Worked solution

By passing a parameter by reference (ByRef), the subroutine receives a reference to the original variable rather than a copy. Any modifications made inside the subroutine directly affect the original Grid variable in the Main procedure.

Marking scheme

1.8 marks for Pass by reference or ByRef.
Question 5 · short-answer
1.8 marks
The skeleton program displays the state of an N x N grid using a nested loop structure within the subroutine DisplayGrid. Identify the Big-O time complexity of this subroutine as a function of the grid size factor N.
Show answer & marking scheme

Worked solution

Since the grid has dimensions N x N and a nested loop is used (the outer loop iterating through rows, and the inner loop iterating through columns), the total number of steps is proportional to N * N = N^2. Therefore, the time complexity is O(N^2).

Marking scheme

1.8 marks for writing O(N^2) or O(N^2) equivalent notation.
Question 6 · short-answer
1.8 marks
The subroutine GetPlayerMove reads a single-character command from the user ('N', 'S', 'E', 'W'). If a user enters the word 'North' instead of 'N', the program might crash or reject the input. Suggest a robust validation/string-handling technique to apply to the user input variable UserInput to extract a valid direction command when full words are entered.
Show answer & marking scheme

Worked solution

To handle 'North', 'north', or any word starting with the direction letter, the program can extract the first character of the input string using indexing and convert this character to uppercase to ensure case-insensitivity.

Marking scheme

1 mark: Suggesting extracting the first character / substring of length 1. 0.8 marks: Suggesting converting the input to uppercase.
Question 7 · short-answer
1.8 marks
The skeleton program represents a grid as a 2D array of characters. If instead, the grid were represented as an array (list) of strings (where each string represents a row), explain why updating a single tile at a given row and column index is more computationally complex in languages with immutable strings (such as Python).
Show answer & marking scheme

Worked solution

Since strings are immutable, you cannot directly assign a new character to an index. Instead, the whole row string must be reconstructed using slicing and concatenation (e.g., Grid[row] = Grid[row][:col] + 'A' + Grid[row][col+1:]), which requires creating a new string object in memory.

Marking scheme

1 mark: Stating that strings are immutable / cannot be modified in-place. 0.8 marks: Explaining the need to reconstruct the string using slicing and concatenation.
Question 8 · short-answer
1.8 marks
Trace the execution of the skeleton program's movement logic. The player starts at coordinates (Row = 0, Col = 0) with a Score of 10. The following sequence of moves is processed: 1) Move 'S' (South: Row increases by 1), 2) Move 'E' (East: Col increases by 1), 3) Move 'S' (South: Row increases by 1). A hazard 'H' exists at coordinate (1, 1) which reduces the Score by 5 upon landing. Assume no other obstacles or bonuses are hit. State the final values of Row, Col, and Score.
Show answer & marking scheme

Worked solution

Start: Row = 0, Col = 0, Score = 10. Move 1 (S): Row = 1, Col = 0. Score remains 10. Move 2 (E): Row = 1, Col = 1. Land on 'H', so Score reduces to 5. Move 3 (S): Row = 2, Col = 1. Score remains 5. Final state: Row = 2, Col = 1, Score = 5.

Marking scheme

0.6 marks for Row = 2. 0.6 marks for Col = 1. 0.6 marks for Score = 5.
Question 9 · Short Answer
1.8 marks
Analyse the following helper function from a mock grid-based game skeleton program: def CheckValidMove(X, Y, D, GridSize): if D == 'N' and Y > 0: return True elif D == 'S' and Y < GridSize - 1: return True elif D == 'E' and X < GridSize - 1: return True elif D == 'W' and X > 0: return True return False. Trace the execution of the function with the arguments CheckValidMove(7, 3, 'E', 8) and state the final boolean value returned.
Show answer & marking scheme

Worked solution

The input parameters are X = 7, Y = 3, D = 'E', and GridSize = 8. Checking the conditions: D == 'N' is false. D == 'S' is false. D == 'E' is true, so we evaluate X < GridSize - 1. This evaluates to 7 < 8 - 1, which simplifies to 7 < 7. This condition is false. Finally, D == 'W' is false. Since no branch evaluates to True, the function falls through to the final line and returns False.

Marking scheme

1.8 marks: Correctly stating 'False' as the returned value. No partial marks.
Question 10 · Short Answer
1.8 marks
Analyse the following subroutine from a skeleton program designed to update a player's energy level: def UpdateEnergy(Energy, MoveType, IsBoostActive): Cost = 10 if MoveType == 'Diagonal': Cost = 15 if IsBoostActive: Cost = Cost * 2 Energy = Energy - Cost if Energy < 0: Energy = 0 return Energy. Trace the execution of this function and determine the exact integer value returned by calling UpdateEnergy(25, 'Diagonal', True).
Show answer & marking scheme

Worked solution

Initialize Cost to 10. The condition MoveType == 'Diagonal' is True, so Cost changes to 15. The condition IsBoostActive is True, so Cost becomes 15 * 2 = 30. Calculate Energy = Energy - Cost, which is 25 - 30 = -5. The condition Energy < 0 is True, so Energy is updated to 0. The function returns 0.

Marking scheme

1.8 marks: Correctly stating '0' as the returned integer. No partial marks.
Question 11 · Short Answer
1.8 marks
Analyse the following Python subroutine from a skeleton program that manages a sorted high-score leaderboard: def InsertHighScore(Scores, NewScore): Placed = False for i in range(len(Scores)): if NewScore > Scores[i]: Scores.insert(i, NewScore) Scores.pop() Placed = True break return Scores. If the list Scores initially contains [120, 95, 80, 70, 50], state the exact contents of the list returned after calling InsertHighScore(Scores, 85).
Show answer & marking scheme

Worked solution

We trace the loop over the list [120, 95, 80, 70, 50] with NewScore = 85. For i = 0 (Scores[0] = 120): 85 > 120 is False. For i = 1 (Scores[1] = 95): 85 > 95 is False. For i = 2 (Scores[2] = 80): 85 > 80 is True. The code inserts 85 at index 2, making the list [120, 95, 85, 80, 70, 50]. Scores.pop() removes the last element (50), leaving [120, 95, 85, 80, 70]. Placed is set to True, and the loop is terminated by break. The list is then returned.

Marking scheme

1.8 marks: Correctly specifying the list [120, 95, 85, 80, 70]. Accept equivalent syntax representing the same elements in the exact same order.

Section C (Paper 1)

Implement active modifications to the skeleton program, adding validations, custom routines, and clear subgrid checks.
3 Question · 30 marks
Question 1 · Program Modification
10 marks
A skeleton program represents an $8 \times 8$ grid-based game board using a 2D array \`Board\` of characters. The board indices run from 0 to 7 for both rows and columns. Empty spaces are represented by \'.\', obstacles by \'X\', and the player by \'P\'.

The current subroutine \`MovePlayer\` is defined as follows:

\`\`\`python
def MovePlayer(Board, CurrentRow, CurrentCol, NewRow, NewCol):
Board[CurrentRow][CurrentCol] = '.'
Board[NewRow][NewCol] = 'P'
return NewRow, NewCol
\`\`\`

This subroutine currently performs no validation.

Modify this subroutine so that it:
1. Checks if the \`NewRow\` and \`NewCol\` coordinates are within the boundaries of the board (index 0 to 7 inclusive).
2. Checks if the destination cell does not contain an obstacle (\'X\').
3. If the move is valid, it updates the board and returns the new coordinates.
4. If the move is invalid (out of bounds or hitting an obstacle), it leaves the board unchanged, prints \'Invalid Move\', and returns the original coordinates (\`CurrentRow\`, \`CurrentCol\`).
Show answer & marking scheme

Worked solution

The modified subroutine first validates the coordinates, then checks for obstacles, and conditionally performs the state change:

\`\`\`python
def MovePlayer(Board, CurrentRow, CurrentCol, NewRow, NewCol):
# Check if new coordinates are within the 8x8 grid boundaries
if NewRow >= 0 and NewRow <= 7 and NewCol >= 0 and NewCol <= 7:
# Check that the target position is not blocked by an obstacle
if Board[NewRow][NewCol] != 'X':
Board[CurrentRow][CurrentCol] = '.'
Board[NewRow][NewCol] = 'P'
return NewRow, NewCol

# Handle invalid scenarios
print("Invalid Move")
return CurrentRow, CurrentCol
\`\`\`

Marking scheme

Marks are awarded as follows:
- **Boundary Check (Row)** [1 mark]: Correctly checking if \`NewRow\` is between 0 and 7 inclusive.
- **Boundary Check (Col)** [1 mark]: Correctly checking if \`NewCol\` is between 0 and 7 inclusive.
- **Obstacle Check** [2 marks]: Correctly checking if \`Board[NewRow][NewCol]\` is not equal to \'X\'.
- **Board Update** [2 marks]: Updating the old position to \'.\' and the new position to \'P\' only when all conditions are met.
- **Error Feedback** [2 marks]: Printing \'Invalid Move\' when any of the validation checks fail.
- **Return Coordinates** [2 marks]: Returning the new coordinates on a valid move, and returning the unchanged original coordinates on an invalid move.
Question 2 · Program Modification
10 marks
A simulation program represents a forest ecosystem using a 2D array \`Forest\` of size $10 \times 10$. Cells contain \'T\' for a tree, \'F\' for a burning tree, and \'.\' for empty ground.

Write a new subroutine \`CountBurningNeighbours(Forest, Row, Col)\` that counts and returns the number of cells adjacent to \`Forest[Row][Col]\` (including diagonals) that contain \'F\'.

The subroutine must safely handle boundary conditions so that it does not attempt to access array indices outside the range 0 to 9.

Provide the complete Python code for this subroutine.
Show answer & marking scheme

Worked solution

The solution implements a nested loop to check neighboring cells while keeping index boundary limits safe using min/max functions or explicit boundary conditions:

\`\`\`python
def CountBurningNeighbours(Forest, Row, Col):
count = 0
# Check row range from Row-1 to Row+1, bound within [0, 9]
start_row = max(0, Row - 1)
end_row = min(9, Row + 1)

# Check column range from Col-1 to Col+1, bound within [0, 9]
start_col = max(0, Col - 1)
end_col = min(9, Col + 1)

for r in range(start_row, end_row + 1):
for c in range(start_col, end_col + 1):
# Skip the target cell itself
if r == Row and c == Col:
continue
# Increment count if neighboring cell is on fire
if Forest[r][c] == 'F':
count += 1
return count
\`\`\`

Marking scheme

Marks are awarded as follows:
- **Loop Structure** [2 marks]: Iterating through the neighboring rows and columns (e.g., offsets -1, 0, 1) or individual manual checks.
- **Boundary Checks** [2 marks]: Ensuring that row and column checks remain strictly within the 0 to 9 index range to avoid array out-of-bounds errors.
- **Self-Exclusion** [2 marks]: Preventing the subroutine from counting the cell itself (at \`Row\`, \`Col\`) if it is on fire.
- **Character Comparison** [2 marks]: Correctly checking if the cell value equals \'F\' and incrementing a running counter.
- **Return Value** [2 marks]: Returning the correct total integer count of burning neighbors.
Question 3 · Program Modification
10 marks
A game skeleton uses a 2D board represented by a $6 \times 7$ array \`Board\` (with 6 rows indexed from 0 to 5, and 7 columns indexed from 0 to 6). Row 5 represents the bottom of the board, and Row 0 represents the top.

Modify or rewrite the subroutine \`PlaceToken(Board, Column, PlayerToken)\` so that it:
1. Validates if the \`Column\` parameter is within the range 0 to 6 inclusive. If not, print \'Invalid Column\' and return \'False\'.
2. Simulates gravity by finding the lowest available empty row in that column (empty cells are represented by \'.\').
3. If an empty row is found, update the board at that coordinate with the \`PlayerToken\' and return \'True\'.
4. If the chosen column is completely full (contains no \'.\'), print \'Column Full\' and return \'False\'.
Show answer & marking scheme

Worked solution

The subroutine must validate input bounds, iterate backwards through the row indices from bottom to top, and place the token when an empty space is detected:

\`\`\`python
def PlaceToken(Board, Column, PlayerToken):
# Step 1: Validate column range
if Column < 0 or Column > 6:
print("Invalid Column")
return False

# Step 2: Traverse from bottom row (5) to top row (0)
for row in range(5, -1, -1):
if Board[row][Column] == '.':
# Step 3: Place token and return True
Board[row][Column] = PlayerToken
return True

# Step 4: Handle full column case
print("Column Full")
return False
\`\`\`

Marking scheme

Marks are awarded as follows:
- **Column Validation** [2 marks]: Correctly validating that \`Column\` is in the range 0 to 6, and returning \'False\' with an appropriate output if invalid.
- **Gravity Traversal** [3 marks]: Implementing a reverse loop from 5 down to 0 to search for the lowest free cell.
- **Cell Checking** [2 marks]: Checking for the placeholder character \'.\' to find an empty slot.
- **Board Update** [2 marks]: Assigning the \`PlayerToken\' directly to the found free slot, and returning \'True\'.
- **Full Column Handling** [1 mark]: Printing \'Column Full\' and returning \'False\' when no cell is empty.

Written Paper (Paper 2)

Answer structured written questions, perform logic gate designs, compile assembly routines, and draft an analytical essay.
23 Question · 61.00000000000001 marks
Question 1 · Short Answer & Conversions
2.2 marks
Convert the denary value \(-83\) into an 8-bit Two's Complement binary integer. Show your working.
Show answer & marking scheme

Worked solution

Method 1: 1. Convert positive 83 to 8-bit binary: \(01010011\) (as \(64 + 16 + 2 + 1 = 83\)). 2. Invert all bits (one's complement): \(10101100\). 3. Add 1 to get the Two's Complement: \(10101100 + 1 = 10101101\). Method 2: Use place values: \(-128, 64, 32, 16, 8, 4, 2, 1\). We can form \(-83\) by taking \(-128 + 32 + 8 + 4 + 1\). This translates directly to the binary sequence \(10101101\).

Marking scheme

1.1 marks: Correct working shown (such as converting positive 83 to binary \(01010011\) or showing a correct place-value calculation). 1.1 marks: Correct final binary representation of \(10101101\).
Question 2 · Short Answer & Conversions
2.2 marks
Simplify the Boolean expression \(A \cdot (\overline{A} + B)\) to its simplest form using Boolean algebra identities. Show your steps.
Show answer & marking scheme

Worked solution

1. Distribute \(A\) over the parenthesis: \(A \cdot \overline{A} + A \cdot B\). 2. Apply the complement law: \(A \cdot \overline{A} = 0\), resulting in \(0 + A \cdot B\). 3. Apply the identity law: \(0 + A \cdot B = A \cdot B\). The simplified expression is \(A \cdot B\) (or \(A \text{ AND } B\)).

Marking scheme

1.1 marks: Applying the distributive law to produce \(A \cdot \overline{A} + A \cdot B\). 1.1 marks: Correctly simplifying the complement term to obtain the final simplified answer \(A \cdot B\).
Question 3 · Short Answer & Conversions
2.2 marks
Convert the hexadecimal value \(C5_{16}\) into its denary equivalent. Show your working.
Show answer & marking scheme

Worked solution

In hexadecimal, \(C\) is equivalent to 12. Using place values: The digit \(C\) represents \(12 \times 16^1 = 12 \times 16 = 192\). The digit \(5\) represents \(5 \times 16^0 = 5 \times 1 = 5\). Adding these together: \(192 + 5 = 197\).

Marking scheme

1.1 marks: Showing the intermediate step of converting the hexadecimal digit \(C\) to 12 and multiplying by 16 to get 192. 1.1 marks: Correctly adding 5 to yield the final denary value of 197.
Question 4 · Short Answer & Conversions
2.2 marks
State the primary role of the Program Counter (PC) register during the Fetch phase of the Fetch-Decode-Execute cycle.
Show answer & marking scheme

Worked solution

The Program Counter (PC) holds the address of the next instruction that is scheduled to be executed. During the Fetch stage, this address is copied to the Memory Address Register (MAR) to request the instruction from memory, and the PC is subsequently incremented to point to the next instruction address.

Marking scheme

1.1 marks: Stating that the PC holds the address of the next instruction to be executed/fetched. 1.1 marks: Mentioning that the address is transferred to the MAR or explaining that the PC is incremented immediately after the fetch step.
Question 5 · Short Answer & Conversions
2.2 marks
State one reason why modern operating systems represent character data using Unicode rather than standard ASCII, and describe how Unicode achieves this.
Show answer & marking scheme

Worked solution

ASCII is limited to 7 or 8 bits, which provides a maximum of 128 or 256 unique character codes. This is only enough for standard English and basic symbols. Unicode was developed using a wider bit layout (such as 16 or 32 bits), allowing for over a million unique code points. This extra capacity allows Unicode to represent characters from multiple languages (e.g., Chinese, Arabic, Cyrillic) and technical symbols simultaneously.

Marking scheme

1.1 marks: Identifying that ASCII has limited capacity (7/8 bits) while Unicode uses more bits (e.g., 16/32 bits). 1.1 marks: Explaining the consequence (Unicode can store characters from many different global languages or specialized symbol sets simultaneously).
Question 6 · Short Answer & Conversions
2.2 marks
A Finite State Machine (FSM) acts as an odd parity checker. It starts in state \(S_0\) (even parity, indicating an even number of 1s received). It transitions to state \(S_1\) when an odd number of 1s have been received. Describe the sequence of state transitions that occur when the input string '101' is processed.
Show answer & marking scheme

Worked solution

1. The FSM starts in state \(S_0\). 2. Input '1': The number of 1s becomes odd, so the machine transitions from \(S_0 \rightarrow S_1\). 3. Input '0': The parity does not change, so the machine stays in the same state, transitioning from \(S_1 \rightarrow S_1\). 4. Input '1': The number of 1s becomes even again, so the machine transitions from \(S_1 \rightarrow S_0\). The sequence of state transitions is \(S_0 \rightarrow S_1 \rightarrow S_1 \rightarrow S_0\).

Marking scheme

1.1 marks: Correctly identifying the first transition from \(S_0\) to \(S_1\) upon receiving the first '1'. 1.1 marks: Correctly identifying the remaining transitions (staying in \(S_1\) on '0' and returning to \(S_0\) on the final '1').
Question 7 · Short Answer & Conversions
2.2 marks
Describe how a compiler and an interpreter differ in how they process source code into executable form.
Show answer & marking scheme

Worked solution

A compiler scans the entire high-level program source code and translates it all at once into an independent machine-code executable (or object code) file. Once compiled, the program can run without the compiler. An interpreter does not produce a standalone executable file; instead, it translates the high-level code statement-by-statement, executing each instruction on the fly as it is translated during runtime.

Marking scheme

1.1 marks: Explaining the compiler's behavior (translates whole program into an object/executable file prior to execution). 1.1 marks: Explaining the interpreter's behavior (translates and executes code statement-by-statement or line-by-line during execution).
Question 8 · Short Answer & Conversions
2.2 marks
Explain how data storage and resource management differ between a peer-to-peer network and a client-server network.
Show answer & marking scheme

Worked solution

In a client-server network, resources, files, and authentication databases are stored centrally on one or more dedicated servers. Client workstations must query the central server to access these files. In contrast, a peer-to-peer (P2P) network has no central server; all computers (peers) have equal status and share their own local data and resources directly with other workstations on the network.

Marking scheme

1.1 marks: Explicitly identifying that a client-server network relies on centralized data storage on a dedicated server. 1.1 marks: Explaining that a peer-to-peer network distributes resource storage across individual participating nodes without a central authority.
Question 9 · Short Answer
2.2 marks
Convert the hexadecimal number C3 to both unsigned decimal and 8-bit binary.
Show answer & marking scheme

Worked solution

To convert C3 to binary: C in hex is 12 in decimal, which is 1100 in binary. 3 in hex is 3 in decimal, which is 0011 in binary. Combining these gives 11000011. To convert C3 to decimal: \(12 \times 16^1 + 3 \times 16^0 = 192 + 3 = 195\).

Marking scheme

1 mark for correct decimal conversion (195). 1.2 marks for correct 8-bit binary representation (11000011).
Question 10 · Short Answer
2.2 marks
Using Boolean identities, simplify the following Boolean expression: \( A \cdot B + A \cdot (B + C) + B \cdot (B + C) \). Show your working.
Show answer & marking scheme

Worked solution

Step 1: Expand the terms: \( A \cdot B + A \cdot B + A \cdot C + B \cdot B + B \cdot C \). Step 2: Apply idempotent law \( A \cdot B + A \cdot B = A \cdot B \) and \( B \cdot B = B \): \( A \cdot B + A \cdot C + B + B \cdot C \). Step 3: Group terms with B: \( B \cdot (A + 1 + C) + A \cdot C \). Step 4: Since \( 1 + X = 1 \), this simplifies to: \( B \cdot (1) + A \cdot C = B + A \cdot C \).

Marking scheme

1 mark for showing valid intermediate expansion/simplification steps (e.g., getting to \( A \cdot B + A \cdot C + B + B \cdot C \)). 1.2 marks for the correct simplified expression \( B + A \cdot C \) (accept \( B + AC \) or equivalent).
Question 11 · Short Answer
2.2 marks
State two differences between assembly language and machine code.
Show answer & marking scheme

Worked solution

1. Assembly language uses human-readable mnemonics (like ADD, SUB) and labels, whereas machine code is composed entirely of binary (1s and 0s) or hexadecimal representation. 2. Assembly language cannot be directly executed by the CPU and requires an assembler to translate it into machine code, whereas machine code is executed directly by the processor.

Marking scheme

1.1 marks for stating that assembly uses mnemonics/labels while machine code is binary. 1.1 marks for stating that assembly requires translation (assembler) whereas machine code is directly executable.
Question 12 · Short Answer
2.2 marks
An uncompressed mono audio file is recorded with a sample rate of 44,100 Hz and a sample resolution of 16 bits. Calculate the storage size of a 10-second recording in kilobytes (kB), assuming 1 kilobyte = 1000 bytes.
Show answer & marking scheme

Worked solution

Step 1: Calculate total bits: \( 44,100 \text{ samples/sec} \times 16 \text{ bits/sample} \times 10 \text{ seconds} \times 1 \text{ channel} = 7,056,000 \text{ bits} \). Step 2: Convert to bytes: \( 7,056,000 / 8 = 882,000 \text{ bytes} \). Step 3: Convert to kilobytes: \( 882,000 / 1000 = 882 \text{ kB} \).

Marking scheme

1 mark for correct method of calculating byte size (e.g., 44100 * 2 * 10). 1.2 marks for the correct final answer of 882 kB (accept 882).
Question 13 · Short Answer
2.2 marks
Explain the role of the Program Counter (PC) register during the Fetch stage of the Fetch-Execute cycle.
Show answer & marking scheme

Worked solution

During the fetch stage, the Program Counter (PC) holds the address of the next instruction to be executed. This address is copied to the Memory Address Register (MAR). Immediately after, or during this cycle, the PC is incremented by one so that it points to the address of the subsequent instruction to be fetched next.

Marking scheme

1.1 marks for stating that the PC holds the address of the next instruction (or copies it to the MAR). 1.1 marks for explaining that the PC is incremented to point to the next instruction.
Question 14 · Short Answer
2.2 marks
Explain one advantage and one disadvantage of using an interpreter compared to a compiler during the software development phase.
Show answer & marking scheme

Worked solution

Advantage: An interpreter allows for easier debugging as errors can be identified immediately during execution, and code can be run instantly without waiting for a lengthy compilation process. Disadvantage: Interpreted execution is slower because translation occurs line-by-line during runtime, and the source code must be distributed to the end user, exposing the proprietary intellectual property.

Marking scheme

1.1 marks for a valid advantage (e.g., faster debugging, instant execution/testing). 1.1 marks for a valid disadvantage (e.g., slower execution speed, source code is exposed/not optimized).
Question 15 · Short Answer
2.2 marks
Explain why the Unicode character set was developed to replace the standard ASCII character set, and state the primary difference in how they represent characters.
Show answer & marking scheme

Worked solution

ASCII uses only 7 bits, allowing for a maximum of 128 unique character codes, which is insufficient for languages other than English. Unicode was developed to represent characters from all global languages, including various scripts, symbols, and emojis. Unicode typically uses 16 or 32 bits per character, providing hundreds of thousands of unique codes compared to ASCII's 128.

Marking scheme

1.1 marks for explaining why Unicode was developed (to support global languages/scripts beyond basic English). 1.1 marks for identifying the difference in bit-width/representation size (e.g., 7-bit ASCII vs 16/32-bit Unicode).
Question 16 · Boolean Algebra & Circuit Drawing
2.2 marks
Simplify the following Boolean expression using Boolean algebra identities: \( Q = A \cdot B + A \cdot (B + C) + B \cdot (B + C) \). Show your working.
Show answer & marking scheme

Worked solution

Step 1: Expand the terms.
\( Q = A \cdot B + A \cdot B + A \cdot C + B \cdot B + B \cdot C \)

Step 2: Apply the idempotent law \( X \cdot X = X \) and \( X + X = X \).
\( Q = A \cdot B + A \cdot C + B + B \cdot C \)

Step 3: Factor out B from the terms containing B.
\( Q = B \cdot (A + 1 + C) + A \cdot C \)

Step 4: Use the identity \( 1 + X = 1 \).
\( Q = B \cdot (1) + A \cdot C \)
\( Q = B + A \cdot C \)

Marking scheme

1 mark: Correct expansion and application of the idempotent law to obtain a partially simplified intermediate form such as \( A \cdot B + A \cdot C + B + B \cdot C \).
1.2 marks: Correctly simplifying down to the final expression \( B + A \cdot C \) (or equivalent representation like \( B + AC \)).
Question 17 · Boolean Algebra & Circuit Drawing
2.2 marks
Apply De Morgan's Laws and Boolean identities to simplify the following expression to its simplest form: \( Y = \overline{\overline{A \cdot B} + \overline{A + C}} \).
Show answer & marking scheme

Worked solution

Step 1: Apply De Morgan's Law \( \overline{X + Y} = \overline{X} \cdot \overline{Y} \).
\( Y = \overline{\overline{A \cdot B}} \cdot \overline{\overline{A + C}} \)

Step 2: Apply the Double Negation Law \( \overline{\overline{X}} = X \).
\( Y = (A \cdot B) \cdot (A + C) \)

Step 3: Distribute the terms.
\( Y = A \cdot B \cdot A + A \cdot B \cdot C \)

Step 4: Simplify using idempotent law \( A \cdot A = A \).
\( Y = A \cdot B + A \cdot B \cdot C \)

Step 5: Simplify using absorption law \( X + X \cdot Y = X \).
\( Y = A \cdot B \cdot (1 + C) = A \cdot B \)

Marking scheme

1 mark: Correct application of De Morgan's Law and Double Negation to reach \( (A \cdot B) \cdot (A + C) \).
1.2 marks: Correct reduction to the final simplified form \( A \cdot B \) (accept \( AB \)).
Question 18 · Boolean Algebra & Circuit Drawing
2.2 marks
An engineer designs a logic circuit with inputs \( A \), \( B \), and \( C \). Inputs \( A \) and \( B \) are connected to a NAND gate. The output of this NAND gate and input \( C \) are then connected to the inputs of an OR gate. Finally, the output of the OR gate is inverted with a NOT gate to produce output \( Q \). Write down the fully simplified Boolean expression for \( Q \) in terms of \( A \), \( B \), and \( C \).
Show answer & marking scheme

Worked solution

1. Express the intermediate outputs:
- Output of NAND gate: \( \overline{A \cdot B} \)
- Output of OR gate: \( \overline{A \cdot B} + C \)
- Output of NOT gate (final output \( Q \)): \( Q = \overline{\overline{A \cdot B} + C} \)

2. Simplify the expression using De Morgan's Law:
- \( Q = \overline{\overline{A \cdot B}} \cdot \overline{C} \)
- Using the double negation rule: \( Q = (A \cdot B) \cdot \overline{C} \)
- Thus, the fully simplified expression is \( Q = A \cdot B \cdot \overline{C} \) (or \( AB\overline{C} \)).

Marking scheme

1 mark: Formulating the correct unsimplified expression \( Q = \overline{\overline{A \cdot B} + C} \).
1.2 marks: Applying De Morgan's and double negation rules correctly to obtain the final simplified expression \( A \cdot B \cdot \overline{C} \) (accept standard variations like \( AB\overline{C} \) or \( A \cdot B \cdot C' \)).
Question 19 · Boolean Algebra & Circuit Drawing
2.2 marks
Simplify the Boolean expression \( X = (A + \overline{B}) \cdot (A + B) \) using Boolean identities. Show each step of your working.
Show answer & marking scheme

Worked solution

Method 1: Using the Distributive Law
\( (A + \overline{B}) \cdot (A + B) = A + (\overline{B} \cdot B) \)
Since \( \overline{B} \cdot B = 0 \):
\( X = A + 0 = A \)

Method 2: Using Expansion
\( X = A \cdot A + A \cdot B + \overline{B} \cdot A + \overline{B} \cdot B \)
- Since \( A \cdot A = A \) and \( \overline{B} \cdot B = 0 \):
\( X = A + A \cdot B + A \cdot \overline{B} \)
- Factor out A: \( X = A \cdot (1 + B + \overline{B}) \)
- Since \( 1 + Y = 1 \) for any expression Y:
\( X = A \cdot 1 = A \)

Marking scheme

1 mark: Demonstrating a valid first step, either by using the distributive identity to get \( A + (\overline{B} \cdot B) \) or by fully expanding the expression to \( A \cdot A + A \cdot B + \overline{B} \cdot A + \overline{B} \cdot B \).
1.2 marks: Reaching the fully simplified answer \( A \).
Question 20 · Boolean Algebra & Circuit Drawing
2.2 marks
Consider the Boolean identity \( A + \overline{A} \cdot B = A + B \). Calculate how many logic gates are saved if an engineer implements the simplified right-hand side of the identity instead of the direct, unsimplified left-hand side. Assume that:
- A NOT gate is required for each negation.
- Only standard 2-input logic gates (AND, OR) are used for the operations.
- Explain how you derived your answer.
Show answer & marking scheme

Worked solution

1. Unsimplified left-hand side expression: \( A + \overline{A} \cdot B \)
- One NOT gate is needed to produce \( \overline{A} \).
- One AND gate is needed to compute \( \overline{A} \cdot B \).
- One OR gate is needed to compute \( A + (\overline{A} \cdot B) \).
- Total gates required = 3.

2. Simplified right-hand side expression: \( A + B \)
- Only one OR gate is needed.
- Total gates required = 1.

3. Gates saved: \( 3 - 1 = 2 \) gates.

Marking scheme

1 mark: Correctly calculating the gate requirements for both expressions (3 gates for the unsimplified expression and 1 gate for the simplified expression).
1.2 marks: Correct final calculation of 2 gates saved with an explicit explanation of the gates involved (NOT, AND, OR vs. just OR).
Question 21 · Assembly Coding
2.5 marks
An incomplete assembly language program is written using the AQA standard assembly language instruction set.

The program is intended to load an integer value from the memory address labeled `Value1`, multiply it by 4 using logical shift left, subtract 7, and store the final result back into the memory address labeled `Result`.

```assembly
LDR R0, Value1
// [Missing Instruction 1]
// [Missing Instruction 2]
STR R0, Result
HALT
```

Identify the two missing instructions that will complete the program as specified.
Show answer & marking scheme

Worked solution

To complete the program as specified:
1. We need to multiply the loaded value (stored in register `R0`) by 4. Since \(2^2 = 4\), this is achieved by shifting the contents of `R0` left by 2 bits. The instruction is:
`LSL R0, R0, #2`
2. Next, we need to subtract 7 from the result now held in `R0`. The instruction is:
`SUB R0, R0, #7`

Thus, the completed assembly fragment is:
```assembly
LDR R0, Value1
LSL R0, R0, #2
SUB R0, R0, #7
STR R0, Result
HALT
```

Marking scheme

Award marks as follows:
- **1.5 marks** for the first missing instruction: `LSL R0, R0, #2` (Accept equivalent register names if specified, but `R0` is required here. Award 0.5 marks if logical shift left is used with the wrong shift amount, e.g., `#4`).
- **1.0 mark** for the second missing instruction: `SUB R0, R0, #7` (Allow subtraction of register from register if another register was used incorrectly, but must perform subtraction of literal 7).
Question 22 · Assembly Coding
2.5 marks
An assembly language programmer wants to clear (set to 0) the least significant 4 bits of an 8-bit value stored in register `R1`, while leaving the most significant 4 bits unchanged. The result must be stored back in `R1`.

Write a single assembly language instruction, using the `AND` mnemonic and an appropriate immediate value (expressed as a decimal or hexadecimal literal), to perform this operation.
Show answer & marking scheme

Worked solution

To clear specific bits while leaving others unchanged, we perform a bitwise logical `AND` operation using a mask.
- To preserve the most significant 4 bits, the corresponding mask bits must be `1`.
- To clear the least significant 4 bits, the corresponding mask bits must be `0`.

This gives a binary mask of `11110000`.
- Converting `11110000` to decimal: \(128 + 64 + 32 + 16 = 240\). The decimal literal is `#240`.
- Converting `11110000` to hexadecimal: `F0`. The hexadecimal literal is `#&F0` or `#0xF0`.

The resulting assembly instruction is:
`AND R1, R1, #240` or `AND R1, R1, #0xF0`

Marking scheme

Award marks as follows:
- **1.0 mark** for the correct instruction structure and registers: `AND R1, R1, `.
- **1.5 marks** for the correct immediate mask value of `11110000` represented as either decimal `#240` or hexadecimal `#0xF0` (accept `#&F0` or `#F0`).
- (Max 1.0 mark overall if correct mask value is used but with the wrong mnemonic or destination register).
Question 23 · essay
12 marks
A regional health authority plans to introduce an AI-driven triage and consultation smartphone application. The application will collect patient symptoms, physiological data from connected wearable devices (such as heart rate and sleep patterns), and medical history to automatically categorise patients by urgency and, where appropriate, suggest self-care treatments or book GP appointments.

Discuss the ethical (moral), legal, and cultural issues that the regional health authority must consider before implementing this digital healthcare system.
Show answer & marking scheme

Worked solution

To obtain high marks (9-12), responses must balance all three areas (ethical, legal, and cultural) and apply them directly to the scenario of the AI-driven triage app.

Key points to cover:

- **Ethical/Moral**: Detail the algorithmic bias resulting from skewed historical training data. Discuss the ethical dilemma of machine error vs. human doctor error, and who holds responsibility for incorrect triage results.
- **Legal**: Identify key legislation such as the UK Data Protection Act 2018 / GDPR. Discuss requirements for processing sensitive medical ('special category') data. Mention liability laws and regulatory frameworks for medical devices/software.
- **Cultural**: Address the digital divide (socioeconomic and age-based access to technology). Discuss changing cultural expectations of healthcare delivery and potential resistance from traditional demographics.

Marking scheme

Level 3 (9-12 marks):
- Demonstrates a thorough, balanced, and highly coherent understanding of the ethical, legal, and cultural implications.
- Explicitly refers to the scenario (AI triage, wearable data, automated consultations).
- Accurately names and applies relevant legislation (e.g., Data Protection Act 2018 / GDPR).
- Explains complex ethical issues such as AI training bias and accountability.

Level 2 (5-8 marks):
- Covers at least two of the three aspects (ethical, legal, cultural) in reasonable depth, or all three superficially.
- Relates several points back to the healthcare application scenario.
- Mentions general data security or legal terms, though perhaps without deep specific application.

Level 1 (1-4 marks):
- Points are fragmented, superficial, or presented as a basic list.
- Shows limited understanding of the legal or ethical concepts.
- Does not effectively link the issues to the specific scenario of AI triage or wearable data.

Wondering how well you actually know this?

Thinka is an AI practice app for DSE students — unlimited questions, instant auto-marking, and detailed step-by-step solutions. 100,000+ students use it to confirm they actually know it, not just think they do.

Want more questions like this? Practice unlimited on Thinka — instant answers included.

Start Practising Free