You have already learned how to make a linked list and how to add new nodes to the list. What you may not realize is that you have several options of how you choose to add new noded to your list. You saw one example of adding element to the end of the the list. You found the end of the list by starting at the head and running through all the nodes until a next pointer was null. How should you remove elements form the linked list? One option is to always remove the newest node. This is kind of like seniority at the work place. If some one is fired, it is often, or perhaps should be, the most recent hiree. This is also like an ammo clip or magazine (or a pez candy despenser). The bullet to be popped oout next is alway the bullet that was most recently entered. Think of a stack of pancakes. When the cook is making pancakes he puts them one at a time as he make them onto a plate. After twenty minutes the stack may have 15 pancakes and the hotest one will be on top. When he serves them the luck person to be served first will get the most recent pancake. The unlucky last person will get a very cold pancake, it was the first pancake made. Stacks of pancakes pile up and unpile in reverse order. This is called Last In First Out (or Lifo). It is also called a stack or a magazine.

How could we make our linked list function like a stack? All we have to do is write a method pop( ) that returns something of type node and returns which even node was most recently added. To this, all we have to do is run though our linked list and when we get to the end, we know we have reached to node we want to pop off the list. We will have to make the next pointer of the previous node point to null and then simple return a pointer to the last node. Here is a possible implementation of pop( ).

```node pop( node head )
{
if(head==null) //was I given an empty list?
return(null);
node previous = head;//note: I need to keep track of the previous node
while ( head.next != null )
{
previous = head;// I need to update the previous node