62.0k views
0 votes
How does lifo work compared to fifo?

1 Answer

1 vote
Fifo (first-in first-out) is like a super market line at the cash. The person who arrives first will be out first.
===========
in-> | | | | | | | | -> out
============

Lifo (last-in last-out) is like the pile of dishes in a buffet restaurant. Fresh dishes are pushed into the stack. The last dish pushed in will be the first one to pop out when there is a customer needing a dish.
||============ ||============
|| | | | | | | | <- in || | | | | | | | | -> out
||============ ||============
User Burcak
by
8.5k points