stack allows access to only one data itemthe last item inserted if you remove this itemthen you can access the next-to-last item insertedand so on this is useful capability in many programming situations in this sectionwe'll see how stack can be used to check whether parenthesesbracesand brackets are balanced in computer program source file at the end of this we'll see stack playing vital role in parsing (analyzingarithmetic expressions such as *( + stack is also handy aid for algorithms applied to certain complex data structures in "binary trees,we'll see it used to help traverse the nodes of tree in "graphs,we'll apply it to searching the vertices of graph ( technique that can be used to find your way out of mazemost microprocessors use stack-based architecture when method is calledits return address and arguments are pushed onto stackand when it returns they're popped off the stack operations are built into the microprocessor some older pocket calculators used stack-based architecture instead of entering arithmetic expressions using parenthesesyou pushed intermediate results onto stack we'll learn more about this approach when we discuss parsing arithmetic expressions in the last section in this the postal analogy to understand the idea of stackconsider an analogy provided by the postal service many peoplewhen they get their mailtoss it onto stack on the hall table or into an "inbasket at work thenwhen they have spare momentthey process the accumulated mail from the top down first they open the letter on the top of the stack and take appropriate action--paying the billthrowing it awayor whatever when the first letter has been disposed ofthey examine the next letter downwhich is now the top of the stackand deal with that eventually they work their way down to the letter on the bottom of the stack (which is now the topfigure shows stack of mail this "do the top one firstapproach works all right as long as you can easily process all the mail in reasonable time if you can'tthere' the danger that letters on the bottom of the stack won' be examined for monthsand the bills they contain will become overdue of coursemany people don' rigorously follow this top-to-bottom approach they mayfor exampletake the mail off the bottom of the stackso as to process the oldest letter first or they might shuffle through the mail before they begin processing it and put higher-priority letters on top in these casestheir mail system is no longer stack in the computer-science sense of the word if they take letters off the bottomit' queueand if they prioritize itit' priority queue we'll look at these possibilities later