ISRO | ISRO CS 2017 – May | Question 57
The best data structure to check whether an arithmetic expression has balanced parenthesis is a
Answer: (B) Explanation:
Stacks can check equal pair/ balanced pair of parenthesis efficiently. Whenever we get an opening parenthesis we can push it on the stack and when we get the corresponding closing parenthesis, we can pop it. After performing all push and pop operations, if at the end of the expression stack becomes empty then the expression has a balanced parenthesis. Quiz of this Question
Share your thoughts in the comments
Please Login to comment...