Question 1
4 marksA capacity-three stack starts empty. Trace push(8), push(2), pop(), push(5). Give both the popped value and the final top and bottom-to-top snapshot.
Show solution and marking guidance
Indicative answer
- The popped value is 2 (1). The active values end as [8, 5] (1), in bottom-to-top order (1). The final top is 1 (1).