stacks delimiter for properly paired delimitersthe two should match thusif the top of the stack contains left bracket [then the next closing delimiter should be right bracket if the two delimiters matchwe know they are properly paired and can continue processing the source code but if they do not matchthen we know the delimiters are not correct and we can stop processing the file table shows the steps performed by our algorithm and the contents of the stack after each delimiter is encountered in our sample code segment operation stack push push pop match int sumlistint sumlistint valuesint sumlistint values[pop match push current scan line int sumlistint values[]int size int sum int push pop match push push pop match sum +thelisti + pop match pop match whilewhilei size whilei size sum +thelistreturn sumempty table the sequence of steps scanning valid set of delimitersthe operation performed (left columnand the contents of the stack (middle columnas each delimiter is encountered (right columnin the code so farwe have assumed the delimiters are balanced with an equal number of opening and closing delimiters occurring in the proper order but what happens if the delimiters are not balanced and we encounter more opening or closing delimiters than the otherfor examplesuppose the programmer introduced typographical error in the function headerint sumlistint thelist)]int size our algorithm will find the first set of parentheses correct but what happens when the closing bracket is scannedthe result is illustrated in the top part of table you will notice the stack is empty since the left parenthesis was popped