Cambridge O Level Computer Science 2210 · 7.7 Trace tables

Q62 · 2210/23/O/N/24 Q10

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

Q622210/23/O/N/24original Q10Structured · 9 marks
Question 10 from 2210/23/O/N/24

Worked solution

(a)

Run the algorithm one line at a time and only write a value when it changes. Each table scores 2 marks.

MYWORD: it is too short (6 characters) and all upper case, so Accept becomes FALSE twice. The loop is skipped and Rejected is output.

PasswordAcceptIndexFoundOUTPUT
MYWORDTRUE(Please enter password)
FALSE
FALSE
1FALSE
FALSERejected

Password and OUTPUT correct [1]

Accept, Index and Found columns correct [1]

M!word: it is too short, so Accept becomes FALSE. It has mixed case, so line 08 changes nothing. The loop does not run, then NOT Found sets Accept to FALSE.

PasswordAcceptIndexFoundOUTPUT
M!wordTRUE(Please enter password)
FALSE
1FALSE
FALSERejected

Password and OUTPUT correct [1]

Accept, Index and Found columns correct [1]

My!Hidden: it is 9 characters with upper and lower case, so Accept stays TRUE. The loop finds ! at Index 3, so Found becomes TRUE and Index becomes 4.

PasswordAcceptIndexFoundOUTPUT
My!HiddenTRUE(Please enter password)
1FALSE
2FALSE
3TRUE
4
Accepted

Password and OUTPUT correct [1]

Accept, Index and Found columns correct [1]

(b)

Work out the rules from the IF statements.

The length must be at least 8 and no more than 20 characters [1]

It cannot be all upper case or all lower case (it must have both) [1]

It must contain an ! [1]

KEY IDEAIn a trace table, follow each line in order and update only the variables that change.
TOTAL 9 marks

Official mark scheme

Mark scheme for 2210/23/O/N/24 question 10
VIDEO
▶ Topic lesson

A lesson on this topic · by Mr Bulmer's Learning Zone. 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.