LIFO

From Wikipedia, the free encyclopedia

In a stack, the topmost item, which is added last, is taken out first. Hence a stack is a LIFO structure.
In a stack, the topmost item, which is added last, is taken out first. Hence a stack is a LIFO structure.

LIFO stands for last in, first out which in computer science and queueing theory refers to the way items stored in a data structure are processed. The last data to be added to the structure will be the first data to be removed. LIFO mechanisms include data structures such as stacks. Sometimes the term FILO ("first in, last out") is used synonymously.

A LIFO structure can be illustrated with the example of a crowded elevator. When the elevator reaches its destination, the last people to get on are typically the first to get off.

LIFO is also a term used in accounting, for example in determining the cost basis for inventory, and cost of goods sold. See FIFO and LIFO accounting.

[edit] See also