9618/21/M/J/25 question 5: worked solution (May/June 2025, paper 21)

Show as plain text

Cambridge AS Level Computer Science 9618 · 10.4 Introduction to Abstract Data Types (ADT) Worked solution from the Data Types and Structures Paper 2 Problem-solving and Programming booklet, Part 4 of 4. Q82 9618/21/M/J/25 original Q5 Structured · 7 marks Worked solution Move the items from the stack to the queue, then from the queue back to the stack. Any seven of these points score. Pop an item off the stack [1] Add that item to the queue [1] Repeat until the stack is empty [1] Remove an item from the queue [1] Push it onto the stack [1] Repeat until the queue is empty [1] Update the pointers (top of stack, rear and front) each time an item is moved [1] Other points that also score: update the top-of-stack pointer (down) after the pop; update the rear pointer after the add; update the front pointer after the remove; update the top-of-stack pointer (up) after the push. Each of these can score in place of the pointer mark above. Item 6 goes into the queue first and comes out first, so it is pushed first and ends at the bottom of the stack. KEY IDEA A stack reverses order when popped, and a queue keeps order, so moving items stack → queue → stack reverses the stack. TOTAL 7 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by Sir Sikandar Raza. Tap the picture to open it on YouTube.