The correct principle that a stack operates on is Last In First Out (LIFO). This means that the last element added to the stack is the first one to be removed. This principle is often visualized using the analogy of a stack of plates where you can only add or remove the top plate. The stack data structure allows operations mainly at one end:
This ensures that the most recently added element is accessed first, adhering to the LIFO system.
(1) Mid Element First: This is incorrect. Stacks do not operate on the principle of processing the middle element first.
(2) First In First Out: This describes a queue, not a stack. A queue processes elements in the order they were added.
(3) Last In First Out: This is the correct principle for a stack. The last element added (pushed) onto the stack is the first element removed (popped).
(4) Last In Last Out: This doesn't represent a standard data structure principle.
Therefore, a stack works on the principle of (3) Last In First Out.
List-I (Term) | List-II (Description) |
(A) Prefix | (I) In this, the element entered first will be removed last |
(B) Postfix | (II) In this, the element entered first will be removed first. |
(C) Queue | (III) In this, the operator is placed before the operands. |
(D) Stack | (IV) In this, the operator is placed after the operands. |