130k views
3 votes
What behavior do elements in a stack follow? first in, last out, or FILO behavior last in, first out, or LIFO behavior first in, first out, or FIFO behavior last in, last out, or LILO behavior

2 Answers

3 votes

A stack item behaves like Last In First Out, which is equivalent to First In Last Out.

FIFO and LILO are also equivalent, but they describe a queue.

User AbbeGijly
by
6.9k points
5 votes

Answer:

Either First-in-last-out (FILO) or Last-in-first-out (FILO)

Step-by-step explanation:

A stack is a data structure that implements the First-in-last-out (FILO) or Last-in-first-out (FILO) modality. FILO and LIFO are literally the same. They are just alternative ways of saying the same thing. In a stack, the element that is stored in last is retrieved first (LIFO). This also means that the element that is first stored in can be retrieved last.

FIFO which is similar to LILO is used in data structures such as queues but not in stacks.

User Vicmns
by
6.2k points