Multiple choice general knowledge

If you wanted to make sure that the close-parenthesis (the ')' characters) match the open-parenthesis (the '(' characters) in a mathematical expression, which data structure could help you?

  1. Stack

  2. Tree

  3. Hash Table

  4. Linked List

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

A stack is ideal for matching parentheses because it uses Last-In-First-Out (LIFO) order. When you see a closing parenthesis, you check if it matches the most recent opening one on the stack. This is the standard algorithm for expression validation.