Question: undefined Write an algorithm using Stack Data structure to test if a mathematical expression has balanced and matching parentheses. This algorithm will accept an expression
undefined
Write an algorithm using Stack Data structure to test if a mathematical expression has balanced and matching parentheses. This algorithm will accept an expression character by character as input along with a stack. The expression can use one of the following parentheses: (.) (.). {} The input expressions can also have variables and operators, which must be ignored from processing. For example, an expression (a + {c * d) (e-d)] has matching parenthesis leaving out the variables and operators. That is, the parenthesis sequence [{} ( ), ignoring the variables and operators, is a valid sequence. Further, the expression (a + c * d} {e+d)] do not have matching parenthesis as in the corresponding parenthesis sequence [( ], the curly braces does not match. [4M]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
