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

Study the following pseudocode. Line numbers are for reference only. 10 PROCEDURE Encode () 11 DECLARE CountA, CountB, ThisNum : INTEGER 12 DECLARE ThisChar : CHAR 13 DECLARE Flag : BOOLEAN 14 CountA ← 0 15 CountB ← 10 16 Flag ← TRUE 17 INPUT ThisNum 18 WHILE ThisNum <> 0 19 ThisChar ← LEFT(NUM_TO_STR(ThisNum), 1) 20 IF Flag = TRUE THEN 21 CASE OF ThisChar 22 '1' : CountA ← CountA + 1 23 '2' : IF CountB < 10 THEN 24 CountA ← CountA + 1 25 ENDIF 26 '3' : CountB ← CountB – 1 27 '4' : CountB ← CountB – 1 28 Flag ← FALSE 29 OTHERWISE : OUTPUT "Ignored" 30 ENDCASE 31 ELSE 32 IF CountA > 2 THEN 33 Flag ← NOT Flag 34 OUTPUT "Flip" 35 ELSE 36 CountA ← 4 37 ENDIF 38 ENDIF 39 INPUT ThisNum 40 ENDWHILE 41 OUTPUT CountA 42 ENDPROCEDURE

  1. (a)Procedure Encode() contains a loop structure. Identify the type of loop and state the condition that ends the loop. Do not include pseudocode statements in your answer. Type Condition[2]
  2. (b)Complete the trace table below by dry running the procedure Encode() when the following values are input: 12, 24, 57, 43, 56, 22, 31, 32, 47, 99, 0 The first row is already complete. ThisNum ThisChar CountA CountB Flag OUTPUT 0 10 TRUE [6]
  3. (c)Procedure Encode() is part of a modular program. Integration testing is to be carried out on the program. Describe integration testing.[2]

Mark scheme

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

  1. [2] One mark for type and one mark for condition: Independent marks
  2. Type: pre-condition
  3. Condition: when the value of ThisNum / the input value is equal to zero
  4. [6] Marks as follows: One mark per outlined group If no marks per group then mark by columns (columns 3 to 6) for max 4
  5. ThisNum | ThisChar | CountA | CountB | Flag | OUTPUT
  6. | | 0 | 10 | TRUE |
  7. 12 | '1' | 1 | 10 | TRUE |
  8. 24 | '2' | 2 | 10 | TRUE |
  9. 57 | '5' | 2 | 10 | TRUE | "Ignored"
  10. 43 | '4' | 2 | 9 | FALSE| "Ignored"
  11. 56 | '5' | 2 | 9 | FALSE|
  12. 22 | '2' | 4 | 9 | TRUE | "Flip"
  13. 31 | '3' | 4 | 8 | TRUE |
  14. 32 | '3' | 4 | 7 | TRUE |
  15. 47 | '4' | 4 | 6 | FALSE|
  16. 99 | '9' | 4 | 6 | FALSE| "Ignored"
  17. 0 | | 4 | 6 | FALSE|
  18. [2] One mark per point:
  19. • Modules that have already been tested individually
  20. • are combined into a single (sub) program which is then tested as a whole

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, 10 marks.
Source
A-Level Computer Science, May/June 2022 Paper 2 Variant 2, 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