Cambridge O Level Computer Science 2210 · 7.7 Trace tables

Q55 · 2210/21/M/J/23 Q7

Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8.

Q552210/21/M/J/23original Q7Structured · 7 marks
Question 7 from 2210/21/M/J/23

Worked solution

(a)

Run the flowchart. Pointer is set to 1, then a letter is input. Pointer goes up by 1 each time Word[Pointer, 1] is not the letter. F is at index 6 and D is at index 4.

PointerLetterChoiceOUTPUT
1F
2
3
4
5
6Letter F is represented by Foxtrot
Another Letter? (Y or N)
Y
1D
2
3
4Letter D is represented by Delta
Another Letter? (Y or N)
N

Pointer column correct [1]

Letter column correct [1]

Choice column correct [1]

OUTPUT column correct [1]

(b)

The algorithm looks at each item in turn until it finds the one it wants.

Write: (linear) search [1]

(c)

Any one problem, with its reason:

The algorithm would not stop (it keeps looping) [1]

... because an invalid character is never found in the array, so Pointer keeps going up past 13 and the program may crash [1]

KEY IDEAA linear search checks each item in order, so an input that is not in the list makes it run off the end.
TOTAL 7 marks

Official mark scheme

Mark scheme for 2210/21/M/J/23 question 7
VIDEO
▶ Whole paper

Video solution of the whole paper · by ZAINEMATICS. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.