Cambridge IAS-Level · PastPaper.sampleTitle

MetadataPastPaper.sampleTitle

Thinka Nov 2024 (V1) Cambridge International A Level-Style Mock — Computer Science (9618)

150 PastPaper.marks210 PastPaper.minutes2024
An original Thinka practice paper modelled on the structure and difficulty of the Nov 2024 (V1) Cambridge International A Level Computer Science (9618) paper. Not affiliated with or reproduced from Cambridge.

Paper 11 Fundamentals of Theory

Answer all questions. Calculators must not be used. Write clearly in the spaces provided.
15 PastPaper.question · 29.999999999999996 PastPaper.marks
PastPaper.question 1 · Short Answer
2 PastPaper.marks
Define the software classification 'shareware'.
PastPaper.showAnswers

PastPaper.workedSolution

Shareware refers to a type of software distribution model where users are allowed to try the software for free during a trial period. Typically, some features may be disabled, or the software will cease to function after the trial period unless a license fee is paid. The source code is not provided.

PastPaper.markingScheme

1 mark for stating it is distributed free of charge for a trial/limited period. 1 mark for stating that payment/purchase is required for continued use or full functionality.
PastPaper.question 2 · Short Answer
2 PastPaper.marks
Define the term 'data validation'.
PastPaper.showAnswers

PastPaper.workedSolution

Data validation is a process carried out by software to verify that the entered data meets specific criteria (e.g., range check, length check, format check). It ensures that the data is valid, though it cannot guarantee that the data is accurate or correct.

PastPaper.markingScheme

1 mark for identifying it as an automatic software/computer check (on input data). 1 mark for stating its purpose is to ensure data is reasonable, sensible, or conforms to rules/criteria (do NOT accept 'proves data is correct/accurate').
PastPaper.question 3 · Short Answer
2 PastPaper.marks
Define the term 'CSMA/CD' (Carrier Sense Multiple Access with Collision Detection).
PastPaper.showAnswers

PastPaper.workedSolution

CSMA/CD is a protocol used to handle collisions on shared network mediums. A node wishing to transmit first 'listens' to the bus (carrier sense). If the bus is idle, it transmits. If two nodes transmit simultaneously, a collision occurs. The nodes detect this collision, stop transmitting immediately, send a jam signal, and wait a random amount of time before retrying.

PastPaper.markingScheme

1 mark for describing 'carrier sense' (listening to the medium before transmitting to see if it is busy). 1 mark for describing 'collision detection' (detecting a collision, stopping transmission, and sending a jam signal / waiting a random time).
PastPaper.question 4 · Short Answer
2 PastPaper.marks
Define the term 'actuator'.
PastPaper.showAnswers

PastPaper.workedSolution

An actuator is an electromechanical device that is controlled by a computer. When it receives a signal (often converted from digital to analogue), it produces physical movement, such as opening a valve, turning a motor, or operating a pump.

PastPaper.markingScheme

1 mark for identifying it as an output device / hardware component controlled by a computer. 1 mark for stating it converts electrical/control signals into physical movement / mechanical action.
PastPaper.question 5 · Short Answer
2 PastPaper.marks
Define the role of the 'Program Counter (PC)' register.
PastPaper.showAnswers

PastPaper.workedSolution

The Program Counter (PC) is a dedicated register within the control unit of the CPU. Its sole purpose is to store the address in main memory (RAM) where the next instruction to be processed is located. During the fetch stage of the fetch-decode-execute cycle, the PC's contents are copied to the Memory Address Register (MAR), and then the PC is incremented to point to the subsequent instruction.

PastPaper.markingScheme

1 mark for stating it is a CPU register that holds a memory address. 1 mark for specifying that it holds the address of the next instruction to be fetched/executed.
PastPaper.question 6 · Short Answer
2 PastPaper.marks
Define the term 'utility software'.
PastPaper.showAnswers

PastPaper.workedSolution

Utility software is a category of system software that focuses on the infrastructure of the computer itself, helping to keep it running securely and efficiently. Examples include disk defragmenters, antivirus software, file compression tools, and backup software.

PastPaper.markingScheme

1 mark for identifying it as system software (not application software). 1 mark for describing its purpose (to analyze, configure, optimize, or maintain/housekeep the computer).
PastPaper.question 7 · Short Answer
2 PastPaper.marks
Define the term 'foreign key' in the context of relational databases.
PastPaper.showAnswers

PastPaper.workedSolution

In a relational database, a foreign key is used to create a link between two tables. It is an attribute in a 'child' table that matches the primary key of a 'parent' table, ensuring referential integrity and allowing tables to be queried together.

PastPaper.markingScheme

1 mark for stating it is a field/attribute in one table that links to the primary key of another table. 1 mark for stating its purpose is to establish a relationship / link between the tables (or maintain referential integrity).
PastPaper.question 8 · Short Answer
2 PastPaper.marks
Define the term 'sampling resolution' in relation to digital audio.
PastPaper.showAnswers

PastPaper.workedSolution

Sampling resolution determines the precision with which sound amplitudes are recorded. A higher sampling resolution means more bits are used per sample, which increases the dynamic range and reduces quantization noise, but results in a larger file size.

PastPaper.markingScheme

1 mark for stating it is the number of bits. 1 mark for stating that these bits are used to store/represent the amplitude (or value/level) of each sound sample.
PastPaper.question 9 · Data conversion / calculations
1.2 PastPaper.marks
An 8-bit register stores integer values using two's complement representation. What is the 8-bit two's complement representation of denary \(-76\) expressed as a two-digit hexadecimal value?
PastPaper.showAnswers

PastPaper.workedSolution

To convert \(-76\) to 8-bit two's complement:
1. Find the binary for positive 76: \(76 = 64 + 8 + 4\), which is \(01001100_2\).
2. Find the one's complement by inverting the bits: \(10110011_2\).
3. Add 1 to get the two's complement: \(10110011_2 + 1_2 = 10110100_2\).
4. Convert the binary \(10110100_2\) to hexadecimal:
- Left nibble: \(1011_2 = 11_{10} = \text{B}_{16}\)
- Right nibble: \(0100_2 = 4_{10} = 4_{16}\)
Combined, the hexadecimal representation is \(\text{B}4\).

PastPaper.markingScheme

Award marks as follows:
- 0.6 marks for showing the correct 8-bit two's complement binary representation (\(10110100\)).
- 0.6 marks for converting the binary representation into the correct hexadecimal string (\(\text{B}4\)).
Accept: 'B4' or '0xB4'. Reject: incorrect hex digits.
PastPaper.question 10 · Data conversion / calculations
1.2 PastPaper.marks
Convert the denary number 385 into a 12-bit natural Binary Coded Decimal (BCD) format.
PastPaper.showAnswers

PastPaper.workedSolution

In Binary Coded Decimal (BCD), each decimal digit is converted individually into its equivalent 4-bit binary representation (nibble):
- The digit 3 becomes \(0011_2\)
- The digit 8 becomes \(1000_2\)
- The digit 5 becomes \(0101_2\)
Concatenating these together gives: \(0011\ 1000\ 0101\).

PastPaper.markingScheme

Award marks as follows:
- 0.4 marks for each correct 4-bit BCD nibble:
- 3 -> \(0011\)
- 8 -> \(1000\)
- 5 -> \(0101\)
Allow spaces between nibbles. Reject any 8-bit or pure binary conversion of 385.
PastPaper.question 11 · Data conversion / calculations
1.2 PastPaper.marks
The ASCII character code for 'A' is 65 in denary (hexadecimal 41). Calculate the hexadecimal ASCII representation for the character 'K'.
PastPaper.showAnswers

PastPaper.workedSolution

1. Determine the character distance between 'A' and 'K':
- 'A' is 1st letter, 'K' is 11th letter of the alphabet.
- Difference = \(11 - 1 = 10\).
2. Calculate the denary code for 'K':
- Denary code = \(65 + 10 = 75\).
3. Convert 75 to hexadecimal:
- \(75 / 16 = 4\) with a remainder of \(11\).
- Since \(11_{10} = \text{B}_{16}\), the hexadecimal value is \(4\text{B}\).

PastPaper.markingScheme

Award marks as follows:
- 0.6 marks for calculating the correct denary ASCII value of 'K' (75).
- 0.6 marks for correctly converting 75 to hexadecimal (\(4\text{B}\)).
Accept: '4B' or '4b'. Reject: any other value.
PastPaper.question 12 · Data conversion / calculations
1.2 PastPaper.marks
A mono audio recording is 64 seconds long. It is sampled at a frequency of 8,000 Hz, with a sampling resolution of 16 bits. Calculate the final file size of the recording in kibibytes (KiB).
PastPaper.showAnswers

PastPaper.workedSolution

To calculate the file size in KiB:
1. Total size in bits = \(\text{Duration in seconds} \times \text{Sampling rate} \times \text{Resolution} \times \text{Channels}\)
- Total size = \(64 \times 8000 \times 16 \times 1 = 8,192,000 \text{ bits}\)
2. Convert bits to bytes:
- \(8,192,000 \text{ bits} / 8 = 1,024,000 \text{ bytes}\)
3. Convert bytes to kibibytes (KiB):
- \(1,024,000 \text{ bytes} / 1024 = 1000 \text{ KiB}\).

PastPaper.markingScheme

Award marks as follows:
- 0.6 marks for correctly calculating the total bytes (\(1,024,000\) bytes) or bits (\(8,192,000\) bits).
- 0.6 marks for dividing the bytes by 1024 to yield the correct final integer value of \(1000\).
Accept: '1000' or '1000 KiB'.
PastPaper.question 13 · Data conversion / calculations
1.2 PastPaper.marks
Perform the binary subtraction \(01001100_2 - 00011011_2\) using 8-bit two's complement addition. Show your final answer as an 8-bit binary pattern.
PastPaper.showAnswers

PastPaper.workedSolution

To subtract \(00011011_2\) from \(01001100_2\) using two's complement addition:
1. Find the two's complement of the subtrahend \(00011011_2\):
- Invert bits (one's complement): \(11100100_2\)
- Add 1: \(11100101_2\)
2. Add this value to the minuend \(01001100_2\):
- \(01001100_2 + 11100101_2 = 100110001_2\)
3. Since we are using an 8-bit register, ignore the carry-out bit beyond 8 bits to get the final 8-bit binary result: \(00110001_2\).
Verification in denary: \(76 - 27 = 49\), and \(00110001_2 = 32 + 16 + 1 = 49\).

PastPaper.markingScheme

Award marks as follows:
- 0.6 marks for correctly identifying the 8-bit two's complement representation of \(-27\) (\(11100101\)).
- 0.6 marks for correctly adding the values and providing the final truncated 8-bit binary result (\(00110001\)).
Reject: answers with fewer or more than 8 bits.
PastPaper.question 14 · practical
4 PastPaper.marks
A database contains a table named Student.
Write an SQL script to define a new database table named Enrollment with the following fields and constraints:

- EnrollmentID: integer, acts as the primary key.
- StudentID: integer, acts as a foreign key referencing the StudentID field in the Student table.
- ClubName: variable-length character field of maximum length 30, which cannot be empty (must not contain null values).
- DateJoined: date field.
PastPaper.showAnswers

PastPaper.workedSolution

To define the table with the correct constraints, standard DDL (Data Definition Language) must be used:

1. Define the table name using `CREATE TABLE Enrollment`.
2. Define each attribute with its appropriate data type (e.g., `INT` or `INTEGER`, `VARCHAR(30)` or `CHARACTER(30)`, and `DATE`).
3. Enforce key constraints: `EnrollmentID` as the `PRIMARY KEY`, and `StudentID` as a `FOREIGN KEY` referencing the `Student` table.
4. Apply the `NOT NULL` constraint to the `ClubName` field.

Example complete script:
```sql
CREATE TABLE Enrollment (
EnrollmentID INT PRIMARY KEY,
StudentID INT,
ClubName VARCHAR(30) NOT NULL,
DateJoined DATE,
FOREIGN KEY (StudentID) REFERENCES Student(StudentID)
);
```

PastPaper.markingScheme

1 mark: Correct `CREATE TABLE Enrollment` syntax including opening and closing parentheses.
1 mark: `EnrollmentID` defined as an integer and specified as the `PRIMARY KEY` (either inline or as a separate constraint).
1 mark: `ClubName` defined as `VARCHAR(30)` (or `CHAR(30)`) with `NOT NULL` constraint.
1 mark: Correct definition of `StudentID` as a `FOREIGN KEY` referencing `Student(StudentID)`.
PastPaper.question 15 · practical
4 PastPaper.marks
A bookstore database contains two tables with the following schemas:

- Book(BookID, Title, AuthorID, Genre, Price)
- Author(AuthorID, AuthorName, Country)

Write an SQL query to retrieve and display the Title of the book and the corresponding AuthorName for all books where the Genre is 'Science Fiction' and the Price is less than 15.00. The resulting records must be sorted in alphabetical order of the book Title.
PastPaper.showAnswers

PastPaper.workedSolution

The query requires elements from both tables, meaning a table join is needed:

1. Select the target columns: `Book.Title` and `Author.AuthorName`.
2. Use a join to link both tables together: `FROM Book INNER JOIN Author ON Book.AuthorID = Author.AuthorID`.
3. Filter results with the `WHERE` clause: `WHERE Book.Genre = 'Science Fiction' AND Book.Price < 15.00`.
4. Sort the result set: `ORDER BY Book.Title` (ASC is default, but can be written explicitly).

Example query:
```sql
SELECT Book.Title, Author.AuthorName
FROM Book
INNER JOIN Author ON Book.AuthorID = Author.AuthorID
WHERE Book.Genre = 'Science Fiction' AND Book.Price < 15.00
ORDER BY Book.Title ASC;
```

PastPaper.markingScheme

1 mark: Correct `SELECT` clause specifying `Book.Title` and `Author.AuthorName` (table qualifiers optional but recommended).
1 mark: Correct `FROM` clause with an inner join linking `Book` and `Author` on the common field `AuthorID`.
1 mark: Correct `WHERE` clause with two conditions combined with an `AND` operator (`Genre = 'Science Fiction' AND Price < 15.00`).
1 mark: Correct `ORDER BY` clause to sort alphabetically by `Title` (or `Book.Title`).

Paper 21 Problem-Solving & Programming Skills

Answer all questions. Use the accompanying insert document containing standard pseudocode operations.
8 PastPaper.question · 43 PastPaper.marks
PastPaper.question 1 · Code debugging & validation plan mapping
4 PastPaper.marks
A programmer writes a pseudocode function to search a 1-indexed array `DataArray` containing 100 integers, to find the first index where the element is greater than or equal to a given `Threshold`. The function should return the index if found, or -1 if no such element exists.

01 FUNCTION FindThreshold(DataArray : ARRAY, Threshold : INTEGER) RETURNS INTEGER
02 DECLARE Index : INTEGER
03 DECLARE Found : BOOLEAN
04 Index <- 1
05 Found <- FALSE
06 WHILE Index < 100 AND NOT Found
07 IF DataArray[Index] >= Threshold THEN
08 Found <- TRUE
09 ELSE
10 Index <- Index + 1
11 ENDIF
12 ENDWHILE
13 IF Found THEN
14 RETURN Index
15 ELSE
16 RETURN -1
17 ENDIF
18 ENDFUNCTION

There is an error in the pseudocode.

Identify the line number with the error, provide the corrected line of code, and describe a boundary test case (including sample input data and expected output) that can be used to validate the corrected program.
PastPaper.showAnswers

PastPaper.workedSolution

1. Line containing error: Line 06 (1 mark)
2. Corrected line: WHILE Index <= 100 AND NOT Found (1 mark)
3. Boundary test case: An array where the matching value is placed exactly at index 100, and no matching values exist before index 100 (1 mark)
4. Expected output: The function returns 100 under the corrected code, whereas the buggy code would return -1 because it terminates without checking index 100 (1 mark).

PastPaper.markingScheme

1 mark: Correctly identify Line 06 as the line with the error.
1 mark: Provide the correct replacement code 'WHILE Index <= 100 AND NOT Found'.
1 mark: Describe a boundary test case where the matching target is at index 100 (and other indexes are non-matching).
1 mark: State the expected output of 100 for the boundary test case to validate the correct behavior.
PastPaper.question 2 · Code debugging & validation plan mapping
4 PastPaper.marks
An algorithm is designed to validate a username string. The username must be between 5 and 10 characters long, inclusive.

The programmer writes the following pseudocode function:

01 FUNCTION ValidateUsername(Username : STRING) RETURNS BOOLEAN
02 DECLARE Length : INTEGER
03 Length <- LENGTH(Username)
04 IF Length > 5 AND Length < 10 THEN
05 RETURN TRUE
06 ELSE
07 RETURN FALSE
08 ENDIF
09 ENDFUNCTION

Identify the line containing the error, write the corrected version of the line, and describe two boundary test cases (one that should be valid, and one that should be invalid) to validate the corrected function.
PastPaper.showAnswers

PastPaper.workedSolution

The error is that the comparison operators are exclusive (> and <) rather than inclusive (>= and <=). Therefore, usernames of length 5 and 10 will incorrectly fail validation.

Correction: Use >= and <=

Boundary validation requires testing values exactly on the boundary limit (5 and 10) and just outside them (4 and 11).

PastPaper.markingScheme

1 mark: Identify line 04 containing the error.
1 mark: Provide correct line 'IF Length >= 5 AND Length <= 10 THEN'.
1 mark: Outline a valid boundary test case of length 5 or 10, expecting TRUE.
1 mark: Outline an invalid boundary test case of length 4 or 11, expecting FALSE.
PastPaper.question 3 · Code debugging & validation plan mapping
4 PastPaper.marks
The following pseudocode is designed to find the minimum value in a non-empty 1D array `Scores` containing 50 positive integers (indexed 1 to 50).

01 FUNCTION FindMin(Scores : ARRAY) RETURNS INTEGER
02 DECLARE MinVal : INTEGER
03 DECLARE Index : INTEGER
04 MinVal <- 0
05 FOR Index <- 1 TO 50
06 IF Scores[Index] < MinVal THEN
07 MinVal <- Scores[Index]
08 ENDIF
09 ENDFOR
10 RETURN MinVal
11 ENDFUNCTION

Identify the line containing the logical error, write the corrected version of the line, and describe a test case (input array details and expected output) that would fail under the buggy code but pass under the corrected code.
PastPaper.showAnswers

PastPaper.workedSolution

The logical error is in initializing MinVal to 0. Since the array contains positive integers, no value will ever be less than 0, meaning the condition on line 06 will never be met and the function will always return 0.
Initializing to the first element (Scores[1]) solves this.

PastPaper.markingScheme

1 mark: Identify line 04.
1 mark: Provide corrected line 'MinVal <- Scores[1]'.
1 mark: Describe a test case where all integers are positive.
1 mark: Explain that the buggy code incorrectly outputs 0, whereas the corrected code successfully outputs the actual minimum value.
PastPaper.question 4 · Code debugging & validation plan mapping
4 PastPaper.marks
A function is designed to calculate a customer's loyalty discount based on their purchase amount.
- If the purchase amount is greater than $100.00, they get a 10% discount (0.10).
- If the purchase amount is greater than $200.00, they get a 20% discount (0.20).
- Otherwise, they get no discount (0.0).

The programmer writes the following code:

01 FUNCTION CalculateDiscount(Amount : REAL) RETURNS REAL
02 DECLARE Discount : REAL
03 Discount <- 0.0
04 IF Amount > 100.0 THEN
05 Discount <- 0.10
06 ELSEIF Amount > 200.0 THEN
07 Discount <- 0.20
08 ENDIF
09 RETURN Discount
10 ENDFUNCTION

(a) Explain why this function contains a logic error.
(b) Provide the corrected pseudocode block for lines 04 to 08 to resolve this error.
PastPaper.showAnswers

PastPaper.workedSolution

The nested checks must go from the most restrictive condition (greatest value) to the least restrictive condition. Checking > 100.0 first shadow-blocks the check for > 200.0.

Corrected Pseudocode:
IF Amount > 200.0 THEN
Discount <- 0.20
ELSEIF Amount > 100.0 THEN
Discount <- 0.10
ENDIF

PastPaper.markingScheme

1 mark: State that amounts greater than 200.0 are also greater than 100.0.
1 mark: Explain that because of this, the first branch triggers and skips the 20% discount branch entirely.
1 mark: Reorder the checks to test 'Amount > 200.0' first.
1 mark: Correctly use ELSEIF 'Amount > 100.0' and preserve structure.
PastPaper.question 5 · Algorithm & Pseudocode design
6.75 PastPaper.marks
An algorithm is required to process an array of 50 integers and find the length of the longest contiguous sub-sequence of even numbers.

Write pseudocode for a function `LongestEvenSequence(Numbers : ARRAY[1:50] OF INTEGER) RETURNS INTEGER` to implement this algorithm.
PastPaper.showAnswers

PastPaper.workedSolution

The function initializes tracking variables `MaxSeq` and `CurrentSeq` to 0. It iterates through the array from indices 1 to 50 using a `FOR` loop. For each index, it checks if `Numbers[i]` is even (using `MOD 2 = 0`). If it is even, the current contiguous sequence counter (`CurrentSeq`) is incremented, and we update `MaxSeq` if `CurrentSeq` exceeds it. If an odd number is encountered, `CurrentSeq` is reset to 0. Finally, `MaxSeq` is returned.

PastPaper.markingScheme

1 Mark: Correct function header with parameter, return type, and matching `ENDFUNCTION`.
1 Mark: Correct variable declarations and initialization of tracking variables (`MaxSeq` and `CurrentSeq` to 0).
1 Mark: Correct loop structure traversing indices 1 to 50.
1 Mark: Correct condition to identify even numbers (e.g. `Numbers[i] MOD 2 = 0`).
1 Mark: Correct logic to increment `CurrentSeq` when even and reset it to 0 when odd.
1 Mark: Correct update logic for `MaxSeq` within the even block.
0.75 Mark: Correctly returning `MaxSeq` at the end of the function.
PastPaper.question 6 · Algorithm & Pseudocode design
6.75 PastPaper.marks
A school stores student names and test scores in a text file. The format of the file is alternating lines:
- Line 1: Student Name (STRING)
- Line 2: Test Score (REAL)
- Line 3: Student Name (STRING)
- Line 4: Test Score (REAL)
... and so on.

Write pseudocode for a procedure `CountPassingStudents(FileName : STRING, PassMark : REAL)` that reads the content of the file and outputs the total number of students who achieved a test score greater than or equal to `PassMark`. Use standard Cambridge pseudocode file handling operations.
PastPaper.showAnswers

PastPaper.workedSolution

The procedure opens the specified file in read mode. It uses a loop controlled by the `EOF` function to iterate through the entire file. Inside the loop, two values are read in sequence: first the student's name, then the score as a string. The score is converted to a numeric value using `STRING_TO_NUM` and compared against the `PassMark`. If it is greater than or equal, the counter is incremented. Finally, the file is closed and the count is output.

PastPaper.markingScheme

1 Mark: Correct procedure header with parameters and matching `ENDPROCEDURE`.
1 Mark: Correct use of file handling statements (`OPENFILE` for `READ` and `CLOSEFILE`).
1 Mark: Correct end-of-file condition loop structure (`WHILE NOT EOF...`).
1 Mark: Reading both student name and score in sequential order inside the loop.
1 Mark: Converting the read string score to a numeric type (e.g. `STRING_TO_NUM`).
1 Mark: Correct conditional statement to check if the score is greater than or equal to `PassMark` and incrementing the count.
0.75 Mark: Correctly outputting the accumulated count after closing the file.
PastPaper.question 7 · Algorithm & Pseudocode design
6.75 PastPaper.marks
Write pseudocode for a function `GetDomain(Email : STRING) RETURNS STRING` that extracts and returns the domain part of an email address.

The domain part is defined as the substring following the *last* occurrence of the character `"@"`.
If the `"@"` character is not present in the string, or if it is the very last character of the string, the function must return an empty string `""`.

You can use standard built-in string functions:
- `LENGTH(s : STRING) RETURNS INTEGER`
- `MID(s : STRING, start : INTEGER, length : INTEGER) RETURNS STRING`
PastPaper.showAnswers

PastPaper.workedSolution

The function calculates the length of the string and iterates through each character to find the index of the last `@` character. After the loop, it checks if `@` was either not found (index is 0) or is at the very end of the string (index equals the length of the string); if either condition is met, it returns an empty string. Otherwise, it uses `MID` to extract the substring starting from the character after the last `@` to the end of the string.

PastPaper.markingScheme

1 Mark: Correct function header with parameters, return type, and matching `ENDFUNCTION`.
1 Mark: Correctly getting string length using `LENGTH`.
1 Mark: Correct loop from index 1 to length of the string.
1 Mark: Correct character extraction and check to track the index of the *last* occurrence of `"@"`.
1 Mark: Correct conditional checks for the two edge cases (no `"@"` found, or `"@"` at the end of the string).
1 Mark: Correct use of `MID` to extract the domain substring (starting at `LastAtPos + 1` with a length of `Length - LastAtPos`).
0.75 Mark: Correctly returning `""` or the extracted string from all paths.
PastPaper.question 8 · Algorithm & Pseudocode design
6.75 PastPaper.marks
A 2D array `Grid` contains characters and is declared as `Grid : ARRAY[1:10, 1:10] OF CHAR`.
The main diagonal consists of elements where the row index equals the column index (e.g., `Grid[1,1]`, `Grid[2,2]`, etc.).
The anti-diagonal consists of elements where the row index plus the column index equals 11 (e.g., `Grid[1,10]`, `Grid[2,9]`, etc.).

Write pseudocode for a function `CountDiagonals(Grid : ARRAY[1:10, 1:10] OF CHAR, Target : CHAR) RETURNS INTEGER` that counts and returns how many times the character `Target` appears on either of the two diagonals. Note that for a 10x10 grid, the two diagonals do not share any elements.
PastPaper.showAnswers

PastPaper.workedSolution

The function uses a single loop running from 1 to 10 to check both diagonals simultaneously. Since the grid size is 10 by 10, the main diagonal elements are at coordinate `(i, i)` and the anti-diagonal elements are at coordinate `(i, 11 - i)`. Within each iteration, the function compares the elements at these two coordinates with `Target` and increments the tracker variable `Count` accordingly. Finally, the function returns the counted value.

PastPaper.markingScheme

1 Mark: Correct function header with parameters, return type, and matching `ENDFUNCTION`.
1 Mark: Variable declaration and initialization of `Count` to 0.
1 Mark: Single loop header running from 1 to 10.
1 Mark: Correct index checks for the main diagonal (`Grid[i, i]`).
1 Mark: Correct index checks for the anti-diagonal (`Grid[i, 11 - i]`).
1 Mark: Correctly incrementing `Count` independently for both condition hits.
0.75 Mark: Correctly returning `Count` at the end of the function.

PastPaper.sampleCTATitle

PastPaper.sampleCTADescription

PastPaper.sampleStickyMessage

PastPaper.stickyCtaText