2 Stack and queue: basic concepts

A stack is also known as a ``last-in-first-out'' (LIFO) container. Typical real-life examples of stacks include moving trucks (U-Haul), refrigerator, stack of dishes and etc. To add an item to a stack container is to ``push'' the item. To remove an item from a stack container is to ``pop'' the item.

A queue is also known as a ``first-in-first-out'' (FIFO) container. Typical real-life examples include lines at a grocery store or bank.



Copyright © 2006-10-23 by Tak Auyeung