Exam-style question
Try this first
What is the purpose of testing whether a stack is empty before performing a pop operation?.
- A.To ensure there is an element available to remove
- B.To add an element to the stack
- C.To return the top element without removing it
- D.To increase the maximum capacity of the stack
Model answer
What a good answer should say
- To ensure there is an element available to remove
Explanation
Why this works
Testing for an empty stack checks whether a value is available to be removed by pop.
Common mistake
No common mistake is linked to this question yet.
