Which of the following conditions indicates that an array-based stack is full when using zero-based indexing?

Options

  • A. TOP = 0
  • B. TOP = MAX - 1
  • C. TOP = -1
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. TOP = MAX - 1

Detailed Explanation

Correct Answer: B. TOP = MAX - 1

Explanation: In an array-based stack of capacity MAX using zero-based indexing, the last valid index is MAX - 1.

  • Initially, TOP = -1 indicates an empty stack.
  • After inserting the first element, TOP = 0.
  • When TOP = MAX - 1, the stack is full.
  • Another push operation causes overflow.