balanced delimiters number of applications use delimiters to group strings of text or simple data into subparts by marking the beginning and end of the group some common examples include mathematical expressionsprogramming languagesand the html markup language used by web browsers there are typically strict rules as to how the delimiters can be usedwhich includes the requirement of the delimiters being paired and balanced parentheses can be used in mathematical expressions to group or override the order of precedence for various operations to aide in reading complicated expressionsthe writer may choose to use different types of symbol pairsas illustrated here{ ( ( [ ])the delimiters must be used in pairs of corresponding types{}[]and (they must also be positioned such that an opening delimiter within an outer pair must be closed within the same outer pair for examplethe following expression would be invalid since the pair of braces [begin inside the pair of parentheses (but end outside ( [ ){ eanother common use of the three types of braces as delimiters is in the +programming language consider the following code segmentwhich implements function to compute and return the sum of integer values contained in an arrayint sumlistint thelist[]int size int sum int whilei size sum +thelisti ] + return sumas with the arithmetic expressionthe delimiters must be paired and balanced howeverthere are additional rules of the language that dictate the proper placement and use of the symbol pairs we can design and implement an algorithm that scans an input text file containing +source code and determines if the delimiters are properly paired the algorithm will need to remember not only the most recent opening delimiter but also all of the preceding ones in order to match them with closing delimiters in additionthe opening delimiters will need to be remembered in reverse order with the most recent one available first the stack adt is perfect structure for implementing such an algorithm consider the +code segment from earlier as the file is scannedwe can push each opening delimiter onto the stack when closing delimiter is encounteredwe pop the opening delimiter from the stack and compare it to the closing