Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2017 – May | Question 57

Improve Article
Save Article
Like Article
  • Last Updated : 21 Mar, 2018

The best data structure to check whether an arithmetic expression has balanced parenthesis is a
(A) Queue
(B) Stack
(C) Tree
(D) List


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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!