Open In App
Related Articles

ISRO | ISRO CS 2017 – May | Question 57

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report
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

Last Updated : 21 Mar, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads