In an array-based stack, which variable generally indicates the position of the topmost element?

Options

  • A. Front
  • B. Rear
  • C. Top
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

C. Top

Detailed Explanation

Correct Answer: C. Top

Explanation: The Top variable maintains the index of the topmost element in an array-based stack.

  • Initially, Top is generally initialized to -1.
  • After a successful push, Top is incremented.
  • After a successful pop, Top is decremented.
  • When Top = -1, the stack is empty.