2210/21/M/J/23 question 7: worked solution (May/June 2023, paper 21)
Show as plain textHide 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. Q55 2210/21/M/J/23 original Q7 Structured · 7 marks 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. Pointer Letter Choice OUTPUT 1 F 2 3 4 5 6 Letter F is represented by Foxtrot Another Letter? (Y or N) Y 1 D 2 3 4 Letter 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 IDEA A 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 VIDEO ▶ Whole paper Video solution of the whole paper · by ZAINEMATICS. Tap the picture to open it on YouTube.