Correct option is D
A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. This means that the last element inserted (pushed) into the stack will be the first one to be removed (popped).
Hence, deletion (pop operation) always happens from the top of the stack.
Important Key Points:
- Stack operations:
- Push: Inserts an element onto the top of the stack.
- Pop: Removes the topmost element.
- The top pointer keeps track of the most recently added element.
- Stacks are used in function call management, expression evaluation, and recursion handling.
Knowledge Booster:
- The element in the middle of the stack: Cannot be directly accessed; stacks do not allow random access like arrays or lists.
- Any specified element: Invalid; stacks follow strict LIFO order — you cannot delete an arbitrary element.
- The element at the bottom of the stack: Remains until all elements above it are removed; deleted last, not first.