the stack in the workshop applet starts off with four data items already inserted if you want to start with an empty stackthe new button creates new stack with no items the next three buttons carry out the significant stack operations push to insert data item on the stackuse the button labeled push after the first press of this buttonyou'll be prompted to enter the key value of the item to be pushed after typing it into the text fielda few more presses will insert the item on the top of the stack red arrow always points to the top of the stackthat isthe last item inserted notice howduring the insertion processone step (button pressincrements (moves upthe top arrowand the next step actually inserts the data item into the cell if you reversed the orderyou' overwrite the existing item at top when writing the code to implement stackit' important to keep in mind the order in which these two steps are executed if the stack is full and you try to push another itemyou'll get the can' insertstack is full message (theoreticallyan adt stack doesn' become fullbut the array implementing it does pop to remove data item from the top of the stackuse the pop button the value popped appears in the number text fieldthis corresponds to pop(routine returning value againnotice the two steps involvedfirst the item is removed from the cell pointed to by topthen top is decremented to point to the highest occupied cell this is the reverse of the sequence used in the push operation the pop operation shows an item actually being removed from the arrayand the cell color becoming gray to show the item has been removed this is bit misleadingin that deleted items actually remain in the array until written over by new data howeverthey cannot be accessed once the top marker drops below their positionso conceptually they are goneas the applet shows when you've popped the last item off the stackthe top arrow points to - below the lowest cell this indicates that the stack is empty if the stack is empty and you try to pop an itemyou'll get the can' popstack is empty message peek push and pop are the two primary stack operations howeverit' sometimes useful to be able to read the value from the top of the stack without removing it the peek operation does this by pushing the peek button few timesyou'll see the value of the item at top copied to the number text fieldbut the item is not removed from the stackwhich remains unchanged notice that you can only peek at the top item by designall the other items are invisible to the stack user stack size stacks are typically smalltemporary data structureswhich is why we've shown stack of only cells of coursestacks in real programs may need bit more room than thisbut it' surprising how small stack needs to be very long arithmetic expressionfor