Skip to main content
A-LevelComputer ScienceAlgorithm design and problem-solving9618/21 · May/June 2022 · Q56 Marks

Each line of a text file contains data organised into fixed-length fields as shown: <Field 1><Field 2><Field 3> An algorithm is required to search for the first instance of a given value of Field 2 and, if found, to output the corresponding values for Field 1 and Field 3. Describe the algorithm needed. Do not include pseudocode statements in your answer.

  1. (a)Each line of a text file contains data organised into fixed-length fields as shown: <Field 1><Field 2><Field 3> An algorithm is required to search for the first instance of a given value of Field 2 and, if found, to output the corresponding values for Field 1 and Field 3. Describe the algorithm needed. Do not include pseudocode statements in your answer.[6]

Mark scheme

Marking points from the official mark scheme (May/June 2022). The mark or mark type is shown in brackets.

  1. [6] (a) One mark per point to Max 6
  2. [6] (a) 1 Open file in read mode
  3. [6] (a) 2 Set up a conditional loop, repeating until the value is found or the EOF() is reached
  4. [6] (a) 3 Read a line from the file in a loop
  5. [6] (a) 4 Extract Field 2
  6. [6] (a) 5 Description of how Field 2 could be extracted e.g. using substring function and lengths of Field 1 and Field 2
  7. [6] (a) 6 Compare extracted field with search value
  8. [6] (a) 7 If search value found, extract Field 1and Field 3 and output them
  9. [6] (a) 8 Close the file after loop has finished

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Algorithm design and problem-solving, A-Level Computer Science (syllabus 9618). Structured question, 6 marks.
Source
A-Level Computer Science, May/June 2022 Paper 2 Variant 1, question 5.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep