correct)()){([)])correct(()()){([)])})incorrect)()){([)])incorrect({[])incorrectwe leave the precise definition of matching of grouping symbols to exercise - an algorithm for parentheses matching an important problem in processing arithmetic expressions is to make sure their grouping symbols match up correctly we can use stack to perform the matching of grouping symbols in an arithmetic expression with single left-toright scan the algorithm tests that left and right symbols match up and also that the left and right symbols are both of the same type suppose we are given sequence - where each is token that can be grouping symbola variable namean arithmetic operatoror number the basic idea behind checking that the grouping symbols in match correctlyis to process the tokens in in order each time we encounter an opening symbolwe push that symbol onto sand each time we encounter closing symbolwe pop the top symbol from the stack (assuming is not emptyand we check that these two symbols are of the same type if the stack is empty after we have processed the whole sequencethen the symbols in match assuming that the push and pop operations are implemented to run in constant timethis algorithm runs in ( )that is lineartime we give pseudo-code description of this algorithm in code fragment code fragment algorithm for matching grouping symbols in an arithmetic expression