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
Answer and explanation
Concise answer
To ensure there is an element available to remove
Why this is correct
Testing for an empty stack checks whether a value is available to be removed by pop.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
