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.
甲部 (卷一)
Complete trace tables, label state transition diagrams, and write a program matching the pseudo-code logic.
5 題目 · 25 分
題目 1 · structured
5 分
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)?
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 2 · structured
5 分
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)?
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 3 · Diagram Completion
6 分
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]
查看答案詳解收起答案詳解
解題
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.
評分準則
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)
題目 4 · Programming Implementation
4.5 分
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.
查看答案詳解收起答案詳解
解題
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 ```
評分準則
- **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.
題目 5 · Programming Implementation
4.5 分
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 ```
- **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.
乙部 (卷一)
Analyse the skeleton program code without running or active coding; trace logic variables and outline structure.
11 題目 · 19.800000000000004 分
題目 1 · short-answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 2 · short-answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
1.8 marks for either CurrentRow > 0 or CurrentRow - 1 >= 0 (or equivalent boolean logic).
題目 3 · short-answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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).
評分準則
1 mark for stating that 3 items are placed. 0.8 marks for identifying (2, 3) as the duplicate coordinate.
題目 4 · short-answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
1.8 marks for Pass by reference or ByRef.
題目 5 · short-answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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).
評分準則
1.8 marks for writing O(N^2) or O(N^2) equivalent notation.
題目 6 · short-answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
1 mark: Suggesting extracting the first character / substring of length 1. 0.8 marks: Suggesting converting the input to uppercase.
題目 7 · short-answer
1.8 分
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).
查看答案詳解收起答案詳解
解題
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.
評分準則
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.
題目 8 · short-answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
0.6 marks for Row = 2. 0.6 marks for Col = 1. 0.6 marks for Score = 5.
題目 9 · Short Answer
1.8 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
1.8 marks: Correctly stating 'False' as the returned value. No partial marks.
題目 10 · Short Answer
1.8 分
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).
查看答案詳解收起答案詳解
解題
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.
評分準則
1.8 marks: Correctly stating '0' as the returned integer. No partial marks.
題目 11 · Short Answer
1.8 分
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).
查看答案詳解收起答案詳解
解題
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.
評分準則
1.8 marks: Correctly specifying the list [120, 95, 85, 80, 70]. Accept equivalent syntax representing the same elements in the exact same order.
部分 C (卷一)
Implement active modifications to the skeleton program, adding validations, custom routines, and clear subgrid checks.
3 題目 · 30 分
題目 1 · Program Modification
10 分
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:
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\`).
查看答案詳解收起答案詳解
解題
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
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.
題目 2 · Program Modification
10 分
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.
查看答案詳解收起答案詳解
解題
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 \`\`\`
評分準則
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.
題目 3 · Program Modification
10 分
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\'.
查看答案詳解收起答案詳解
解題
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 \`\`\`
評分準則
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 (卷二)
Answer structured written questions, perform logic gate designs, compile assembly routines, and draft an analytical essay.
23 題目 · 61.00000000000001 分
題目 1 · Short Answer & Conversions
2.2 分
Convert the denary value \(-83\) into an 8-bit Two's Complement binary integer. Show your working.
查看答案詳解收起答案詳解
解題
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\).
評分準則
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\).
題目 2 · Short Answer & Conversions
2.2 分
Simplify the Boolean expression \(A \cdot (\overline{A} + B)\) to its simplest form using Boolean algebra identities. Show your steps.
查看答案詳解收起答案詳解
解題
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\)).
評分準則
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\).
題目 3 · Short Answer & Conversions
2.2 分
Convert the hexadecimal value \(C5_{16}\) into its denary equivalent. Show your working.
查看答案詳解收起答案詳解
解題
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\).
評分準則
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.
題目 4 · Short Answer & Conversions
2.2 分
State the primary role of the Program Counter (PC) register during the Fetch phase of the Fetch-Decode-Execute cycle.
查看答案詳解收起答案詳解
解題
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.
評分準則
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.
題目 5 · Short Answer & Conversions
2.2 分
State one reason why modern operating systems represent character data using Unicode rather than standard ASCII, and describe how Unicode achieves this.
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 6 · Short Answer & Conversions
2.2 分
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.
查看答案詳解收起答案詳解
解題
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\).
評分準則
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').
題目 7 · Short Answer & Conversions
2.2 分
Describe how a compiler and an interpreter differ in how they process source code into executable form.
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 8 · Short Answer & Conversions
2.2 分
Explain how data storage and resource management differ between a peer-to-peer network and a client-server network.
查看答案詳解收起答案詳解
解題
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.
評分準則
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.
題目 9 · Short Answer
2.2 分
Convert the hexadecimal number C3 to both unsigned decimal and 8-bit binary.
查看答案詳解收起答案詳解
解題
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\).
評分準則
1 mark for correct decimal conversion (195). 1.2 marks for correct 8-bit binary representation (11000011).
題目 10 · Short Answer
2.2 分
Using Boolean identities, simplify the following Boolean expression: \( A \cdot B + A \cdot (B + C) + B \cdot (B + C) \). Show your working.
查看答案詳解收起答案詳解
解題
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 \).
評分準則
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).
題目 11 · Short Answer
2.2 分
State two differences between assembly language and machine code.
查看答案詳解收起答案詳解
解題
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.
評分準則
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.
題目 12 · Short Answer
2.2 分
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.
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).
題目 13 · Short Answer
2.2 分
Explain the role of the Program Counter (PC) register during the Fetch stage of the Fetch-Execute cycle.
查看答案詳解收起答案詳解
解題
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.
評分準則
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.
題目 14 · Short Answer
2.2 分
Explain one advantage and one disadvantage of using an interpreter compared to a compiler during the software development phase.
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 15 · Short Answer
2.2 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 16 · Boolean Algebra & Circuit Drawing
2.2 分
Simplify the following Boolean expression using Boolean algebra identities: \( Q = A \cdot B + A \cdot (B + C) + B \cdot (B + C) \). Show your working.
查看答案詳解收起答案詳解
解題
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 \)
評分準則
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 \)).
題目 17 · Boolean Algebra & Circuit Drawing
2.2 分
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}} \).
查看答案詳解收起答案詳解
解題
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 \)
評分準則
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 \)).
題目 18 · Boolean Algebra & Circuit Drawing
2.2 分
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 \).
查看答案詳解收起答案詳解
解題
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} \)).
評分準則
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' \)).
題目 19 · Boolean Algebra & Circuit Drawing
2.2 分
Simplify the Boolean expression \( X = (A + \overline{B}) \cdot (A + B) \) using Boolean identities. Show each step of your working.
查看答案詳解收起答案詳解
解題
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 \)
評分準則
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 \).
題目 20 · Boolean Algebra & Circuit Drawing
2.2 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
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).
題目 21 · Assembly Coding
2.5 分
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.
查看答案詳解收起答案詳解
解題
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 ```
評分準則
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).
題目 22 · Assembly Coding
2.5 分
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.
查看答案詳解收起答案詳解
解題
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`
評分準則
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).
題目 23 · essay
12 分
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.
查看答案詳解收起答案詳解
解題
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.
評分準則
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.
想知道自己有幾分把握?
Thinka 是 DSE 學生用的 AI 練習應用程式,有無限量練習題、即時自動批改和詳細解題步驟。逾 100,000 名學生用它確認自己真的識,而不只是「以為識」。