Data Structure Algorithm arithmetic expression


The best data structure to check whether an arithmetic expression has balanced parenthesis is a

  1. Queue
  2. Stack
  3. Tree
  4. List



The data structure required to check whether an expression contains balanced parenthesis is a stack. This is a simple data structure in which elements can be added and removed in a specific order. By Starting with an empty stack, process the parenthesis strings from left to right. If a symbol is an opening parenthesis , push it on the stack as a signal that a corresponding closing symbol needs to appear later. … As long as it is possible to pop the stack to match every closing symbol, the parentheses remain balanced .