Computer PPSC
On which principle does a stack work?
Explanation
A stack is a linear data structure in which insertion and deletion happen from the same end (the top). The last item added is the first one removed, hence Last In, First Out (LIFO).
Related facts:
The opposite principle is FIFO (First In, First Out), used by queues.
Stacks are used in function call management, undo operations, and expression evaluation.
Common stack operations are push (insert) and pop (remove).
Exam tip: A basic data-structure MCQ repeated in computer papers. Stack = LIFO; Queue = FIFO.