CSCA48H3 Lecture Notes - Lecture 5: Item Number, Init, Empty String
Document Summary
Restaurants usually keep dishes in a stack. When a dish is cleaned, we place it on the top of the stack. When a dish is needed, we take one from the top of the stack. So plates are removed in the reverse order of when they were put into the stack. The data which the stack contains is a sequence of arbitrary objects/elements. The objects are extracted and removed in reverse order of which they were inserted. The position where items go in and come out is called the top Add an object o to the top of the stack. Remove and return the object at the top of the stack. This requires that the queue is not empty. A standard queue may also have a top() operation, which returns the item at the head without removing it is_empty(): Returns whether or not the queue is empty (boolean value)