2210/23/O/N/25 question 6: worked solution (October/November 2025, paper 23)

Show as plain text

Cambridge O Level Computer Science 2210 · 7.9 Writing and amending algorithms Worked solution from the Algorithm design and problem-solving Paper 2 Algorithms, Programming and Logic booklet, Part 8 of 8. Q116 2210/23/O/N/25 original Q6 Structured · 9 marks Worked solution (a) Follow the flowchart. It searches ClassList and gives the position, or -1 if the name is not found. Name OUTPUT Ridwan 5 Yan -1 Ella 3 Any two rows correct [1] All three rows correct [1] (b) Write: linear search [1] (c) Set Position and Count, input the name once, then loop through the array until the end or until the name is found. Position ← -1 Count ← 1 OUTPUT "Please enter a name " INPUT Name REPEAT IF Name = ClassList[Count] THEN Position ← Count Count ← 6 ELSE Count ← Count + 1 ENDIF UNTIL Count > 5 OUTPUT Position Position and Count set before the loop [1] Name input before (outside) the loop [1] A suitable loop with a correct condition [1] Name compared with ClassList[Count] [1] Count increased by 1 each time [1] Position output (the position found, or -1) [1] A WHILE loop, or a FOR loop from 1 to 5, is also accepted. KEY IDEA A linear search checks each item in order and keeps the position of the match, or -1 when there is none. 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.