300 Chapter 9 Abstract Data Types and Algorithms Now we Pop off one item at a time and print it. The first item printed is 60, the next item printed is 75, and so on. The original list has now been printed in reverse order using the stack. Any sequence of items put on the stack comes off in reverse order. Queues Queues are an abstract data type in which items are entered at one end and removed from the other end. Accountants call this FIFO, for First In First Out. This sounds like a waiting line in a bank or supermarket. Indeed, queues are used to simulate this type of situation. Insertions are made at the rear of the queue and deletions are made from the front of the queue. Another way of stating the accessing behavior of a queue is that the item removed is the item that has been in the queue the longest time. Viewing a queue from this perspective is more abstract. Like the stack, the insert has no constraints; the entire FIFO behavior is specified in the removal operation. Unfortunately, there is no standard queue terminology
This is the end of the preview.
access the rest of the document.