Question: Given an expression string x . Examine whether the pairs and the orders of { , } , ( , ) , [ , ]

Given an expression string x. Examine whether the pairs and the orders of {,},(,),[,] are correct in expression. For example, the function should return 'BALANCED' for expression =[()]{}{[()()]()} and 'NOT BALANCED' for expression =[(]). Input Format: You will be given a string denoting the given expression Output Format: print BALANCED if given expression is valid other wise print NOT BALANCED Sample Test Case 1: Input: {([])} Output: true Explanation: {([])}. Same colored brackets can form balanced pairs, with 0 number of unbalanced brackets left. Sample Test Case 2: Input: ([] Output: false Explanation: ([]. Here square bracket is balanced but the small bracket is not balanced and Hence , the output will be unbalanced. Show it on C++ program code Given an expression string \(\mathbf{x}\). Examine whether the pairs and the orders of \(\},(),,[\),\(] are correct in \) expression.
For example, the function should return 'BALANCED' for expression =[()]\{\}\{[()()]()\} and 'NOT BALANCED' for expression \(=[(])\).
Input Format: You will be given a string denoting the given expression
Output Format: print "BALANCED" if given expression is valid other wise print "NOT BALANCED"
Sample Test Case 1:
Input: \(\{([])\}\)
Output: true
Explanation: \(\{\)([])\}. Same colored brackets can form balanced pairs, with 0 number of unbalanced brackets left.
Sample Test Case 2:
Input: ([]
Output: false
Explanation: ([]. Here square bracket is balanced but the small bracket is not balanced and Hence , the output will be unbalanced.
Given an expression string x . Examine whether

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!