2210/23/O/N/24 question 10: worked solution (October/November 2024, paper 23)

Show as plain text

Cambridge O Level Computer Science 2210 · 7.7 Trace tables Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 6 of 8. Q62 2210/23/O/N/24 original Q10 Structured · 9 marks 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. Password Accept Index Found OUTPUT MYWORD TRUE (Please enter password) FALSE FALSE 1 FALSE FALSE Rejected 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. Password Accept Index Found OUTPUT M!word TRUE (Please enter password) FALSE 1 FALSE FALSE Rejected 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. Password Accept Index Found OUTPUT My!Hidden TRUE (Please enter password) 1 FALSE 2 FALSE 3 TRUE 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 IDEA In a trace table, follow each line in order and update only the variables that change. TOTAL 9 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.