Home » Programming & Data Structure » Programming and data structure miscellaneous » Question

Programming and data structure miscellaneous

Programming & Data Structure

  1. The best data structure to check whether an arithmetic expression has balanced parenthesis is a
    1. queue
    2. stack
    3. tree
    4. list
Correct Option: B

Balanced parenthesis in an equation are such that the no. of opening and closing parenthesis and in correct order should be there. We can check balancing using stack. When we get any opening parenthesis, then we push that in the stack & if we get a closing one, then we pop the stack. After the complete scanning of input string if stack is found empty then the arithmetic expression is balanced.



Your comments will be displayed only after manual approval.