figure stack of books new items to be added at only one end some structures might allow items to be removed from either end these variations give rise to some of the most useful data structures in computer science they appear in many algorithms and can be used to solve variety of important problems stacks what is stacka stack (sometimes called "push-down stack"is an ordered collection of items where the addition of new items and the removal of existing items always takes place at the same end this end is commonly referred to as the "top the end opposite the top is known as the "base the base of the stack is significant since items stored in the stack that are closer to the base represent those that have been in the stack the longest the most recently added item is the one that is in position to be removed first this ordering principle is sometimes called lifolast-in first-out it provides an ordering based on length of time in the collection newer items are near the topwhile older items are near the base many examples of stacks occur in everyday situations almost any cafeteria has stack of trays or plates where you take the one at the topuncovering new tray or plate for the next customer in line imagine stack of books on desk (figure the only book whose cover is visible is the one on top to access others in the stackwe need to remove the ones that are sitting on top of them figure shows another stack this one contains number of primitive python data objects one of the most useful ideas related to stacks comes from the simple observation of items as they are added and then removed assume you start out with clean desktop now place books one at time on top of each other you are constructing stack consider what happens when you begin removing books the order that they are removed is exactly the reverse of the order that they were placed stacks are fundamentally importantas they can be used to reverse the order of items the order of insertion is the reverse of the order of removal figure shows the python data object stack as it was created and then again as items are removed note the order of the objects considering this reversal propertyyou can perhaps think of examples of stacks that occur as basic data structures