stacks the postfix evaluation algorithm assumes valid expression but what happens if the expression is invalidconsider the following invalid expression in which there are more operands than available operatorsa after applying the algorithm to this expressionthere are two values remaining on the stack as illustrated in table what happens if there are too many operators for the given number of operandsconsider such an invalid expressiona in this casethere are too few operands on the stack when we encounter the addition operatoras illustrated in table if we attempt to perform two pops from the stackan assertion error will be thrown since the stack will be empty on the second pop we can modify the algorithm to detect both types of errors in step ( )we must first verify the stack is not empty before popping an item if the stack is emptywe can stop the evaluation and flag an error the second modification occurs after the evaluation of the entire expression we can pop the result from the stack and then verify the stack is empty if the stack is not emptythe expression was invalid and we must flag an error token alg step stack description ab*cd ab*cd ab*cd (apop top two valuesy (bcompute or push value of push value of ( ab*cd ab*cd ab*cd ( pop top two valuesy ( compute or ( error xxxxxx push result ( of the multiplication xxxxxx push value of push value of push result ( of the addition too many values left on stack table the sequence of algorithm steps when evaluating the invalid postfix expression applicationsolving maze classic example of an application that requires the use of stack is the problem of finding path through maze when viewing maze drawn on paper such