Open In App

LIFO Full Form

Last Updated : 30 Apr, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

LIFO stands for Last In First Out. LIFO was developed as an alternative to the base stock method in inventory accounting and meant that the most recently sold items were recorded as sold first.

LIFO-Full-Form

In technical terms, LIFO means that the element which was stored as the last element will be the first to be removed. It happens so because the new element will be inserted above the existing element and thus the newest element will be available at the top and it will be removed. Thus, the oldest element or the element that was encountered first during this operation will get out last as it will be at the bottom.

Example:

Here, a stack of CDs is available. Now, if we remove the topmost CD, we will be able to access the CD just below it. But if we want to access the CD at the bottom of the stack, we will have to remove all the CDs above it. This will be the only way to access the bottom-most CD.

Characteristics of LIFO

  • Stack, a linear data structure is implemented using the LIFO principle.
  • Elements can be added/ removed from the same end referred to as top.
  • A fixed amount of memory is not consumed as memory utilization will vary with each operation.Thus, a fixed size is not required.

The following general operations are carried out on the Stack data structure

  • Push operation: It means inserting an element at the top of the stack.
  • Pop operation: It means removing the topmost element from the stack.
  • Peek operation: It means returning the topmost element without deleting it from the stack.

Advantages

  • It is easy to implement and understand.
  • It is used in many real-world applications like reversing a string, undo-redo operation and in function calls.

Disadvantages

  • Elements cannot be accessed randomly as LIFO only supports Last In First Out methodology.
  • It is a less flexible method.

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads