views:

311

answers:

4

what LIFO means and which data structure follows the LIFO strategy ?

+9  A: 

"Last in first out"

The classic example is a stack - if you push A, B, C then you'll pop C, B, A in that order.

Compare that with "first in first out" (FIFO) where the classic example is a queue. If you enqueue A, B, C then you'll dequeue A, B, C in that order.

Jon Skeet
Always reminds me of Magic the Gathering effects rules :)
Russ Cam
+2  A: 

LIFO means Last In First Out

A stack is probably the best example. You get two main operations: push, pop.

If

push(firstItem);
push(secondItem);
push(thirdItem);

Then

pop();
pop();
pop();

would return thirdItem, secondItem, then firstItem.

Justin Niessner
A: 

common LIFO structures in the wild: a plate dispenser at a buffet. The last plate inserted onto the stack is the first to come out.

leadingzero
Let's not forget stacks of pancakes. Mmm, pancakes!
Lars Haugseth
But if consumed correctly parts from multiple pancakes nibbles are contained per bite.
Matthew Whited
A: 

patience padawan. all will be revealed in due time.

computer science's existence is almost based on Last in first Out! everytime a program runs it uses a stack. countless algorithms use it.

Victor
guess someone didn't like the Star Wars reference
Matthew Whited