Algorithm Design and Problem-solving: past paper questions
Real questions on algorithm design and problem-solving
The newest 20 of 157 written questions. Open one to see it on the real paper.
- 9618/13 · October/November 2025 · Q7e[3]
The table contains three algorithms that perform data validation. The third algorithm uses the functions MID and LENGTH. The functions MID and LENGTH are defined as follows: • MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString • LENGTH(T...
See it on the paper → - 9618/21 · October/November 2025 · Q5a(i)[1]
Comment on why the programmer chose –1 as the initial value of FoundAt
See it on the paper → - 9618/21 · October/November 2025 · Q5a(ii)[1]
Explain the purpose of the outer conditional clause.
See it on the paper → - 9618/21 · October/November 2025 · Q5a(iii)[1]
The inner conditional clause ensures that only the index of the first matching element, if any, is returned. Explain how this clause works.
See it on the paper → - 9618/21 · October/November 2025 · Q5b(i)[1]
Explain why this is not the most appropriate loop construct.
See it on the paper → - 9618/21 · October/November 2025 · Q5b(ii)[2]
Suggest and justify a more appropriate loop construct that could be used. Construct Justification
See it on the paper → - 9618/21 · October/November 2025 · Q7a[5]
One part of the program contains an algorithm which is represented by a state-transition diagram. Current state Input Output Next state S1 A2 X2 S3 S1 A1 X1 S2 S2 A4 X4 S5 S3 A1 S3 A3 X3 S2 S3 A2 X4 S4 S4 A1 X1 S4 S4 A3 S4 A4 The table shows the inputs, outputs and states for the algorithm: S3 S2 S5 X4 Complete the sta...
See it on the paper → - 9618/21 · October/November 2025 · Q8a[7]
Write efficient pseudocode for the module OKToBorrow()
See it on the paper → - 9618/21 · October/November 2025 · Q8b[8]
A second module is defined: Module Description • ReturnBook() • • • called with two parameters of type STRING representing a StudentID and a BookID searches the array for the relevant loan record when found, sets OnLoan to FALSE and returns TRUE if a loan record is not found, or the book has already been returned, then...
See it on the paper → - 9618/23 · October/November 2025 · Q2a[6]
A program contains a global 1D array of type STRING containing 65 elements. An existing text file is used to store the data in the array. Only non-blank elements (those that do not contain an empty string) are written to the text file. An algorithm will: write the first element of the array as a new line in the text fi...
See it on the paper → - 9618/23 · October/November 2025 · Q5a[4]
Complete the trace table by dry running the procedure when it is called in the statement: CALL Process(1) Index CaseVar Count Num Num Num Num
See it on the paper → - 9618/23 · October/November 2025 · Q5b(i)[1]
Identify the CaseVar values for these two existing clauses. (i)
See it on the paper → - 9618/23 · October/November 2025 · Q6b[7]
A function CheckNumber() will take an integer value and return the Boolean value TRUE if the check digit is correct, otherwise return FALSE Write pseudocode for the function CheckNumber() Assume that the parameter is valid.
See it on the paper → - 9618/23 · October/November 2025 · Q7a[5]
One part of the program contains an algorithm which is represented by a state-transition diagram. The table shows the inputs, outputs and states for the algorithm: Current state Input Output S1 A1 S2 A2 X4 S3 S3 A1 X1 S3 S3 A2 X1 S3 S3 A3 X3 S4 S3 A4 S4 A3 X4 S5 S4 A4 X4 S5 S4 A1 Next state S2 S2 S2 Complete the state-...
See it on the paper → - 9618/31 · October/November 2025 · Q9b[3]
A stack is used to implement recursion. State the three essential features of recursion.
See it on the paper → - 9618/32 · October/November 2025 · Q8b[3]
Convert this Reverse Polish Notation (RPN) back to its original infix form: a b - c + c a - * d /
See it on the paper → - 9618/32 · October/November 2025 · Q8c[4]
The RPN expression: c a / b d – * b + is to be evaluated, where: a = 3, b = 16, c = 9 and d = 6. Show the changing contents of the stack as the RPN expression is evaluated.
See it on the paper → - 9618/32 · October/November 2025 · Q12b[3]
Explain the reasons why a stack is used when a recursive algorithm is executed.
See it on the paper → - 9618/33 · October/November 2025 · Q8[5]
Calculate the shortest distance between the Start node and each of the nodes in the graph using Dijkstra’s algorithm. Show your working on the graph or in the working space. Write your answers in the table provided. V 4 9 T X 3 5 W 3 6 10 Y 22 8 Start Z Working Answers: T V W X Y Z
See it on the paper → - 9618/33 · October/November 2025 · Q11[3]
Describe when the use of recursion would be beneficial and give an example. Description Example
See it on the paper →
What examiners said
The standard of answers seen were very variable. See the earlier comment in the General section concerning the interpretation of the question wording ‘a total of all numbers …’. The answers which gained 4 or all 5 marks were describing something happening to a single number. The key wording of the question was ‘steps …. which could be used to produce pseudocode’. The key steps were: • initialis...
— Examiner report, October/November 2023, 9618/21 Q2(a) (Cambridge)
Generally, well understood and answered. Most solutions correctly had a count-controlled loop, but a not uncommon error was the omission of the assignment arrow. Some solutions attempted a length calculation/check on the string parameter which was not required. A correct solution had the return value done either inside the loop when the count condition was met, or outside the loop. A common error...
— Examiner report, October/November 2023, 9618/21 Q4(a) (Cambridge)
There were many variants seen here producing a correct solution. Some candidates used a twoiteration loop to test each of the array values. This was not needed, and a simpler solution used two conditions joined by the AND operator. However, a common syntax structure error was to write this incorrect statement: Search = Data(Row, 1) OR Data(Row, 2) Many candidates used the correct syntax for the...
— Examiner report, October/November 2023, 9618/21 Q4(b) (Cambridge)
Past papers, syllabus and examiner reports © UCLES (Cambridge University Press & Assessment). Questions are matched to topics from the official syllabus. AssessPro is independent and not endorsed by Cambridge.