Question:

Which of the following is a feature of the "Stack" data structure?

Show Hint

To understand Stack:
- Remember LIFO: Last In, First Out.
- Compare with Queue (FIFO) and Deque (both ends).
- Practice with push/pop operations.
  • Follows a First-In-First-Out (FIFO) order
  • Allows elements to be inserted and removed at both ends
  • Follows a Last-In-First-Out (LIFO) order
  • Does not allow random access to elements
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

To determine the correct feature of the Stack data structure, we need to understand its defining characteristics.
Step 1: Understand the Stack Data Structure
A Stack is a linear data structure that follows the Last-In-First-Out (LIFO) principle, meaning the last element added is the first to be removed.
Operations are typically limited to push (insert) and pop (remove) at one end, known as the top.
Step 2: Analyze Option A - Follows a First-In-First-Out (FIFO) order
FIFO is characteristic of a Queue, not a Stack, where the first element added is the first to be removed.
Thus, option A is incorrect.
Step 3: Analyze Option B - Allows elements to be inserted and removed at both ends
This describes a Deque (double-ended queue), not a Stack, which only allows operations at the top.
Thus, option B is incorrect.
Step 4: Analyze Option C - Follows a Last-In-First-Out (LIFO) order
LIFO is the defining feature of a Stack, where the most recently added element is removed first (e.g., like a stack of plates).
This aligns with the Stack's behavior.
Thus, option C is correct.
Step 5: Analyze Option D - Does not allow random access to elements
While true that Stacks do not support random access (elements can only be accessed via pop from the top), this is a limitation rather than a primary feature.
The question asks for a defining feature, making LIFO more appropriate.
Thus, option D is not the best answer but is a secondary characteristic.
Step 6: Conclusion
The primary feature of a Stack is its LIFO order, making option C the correct answer.
Was this answer helpful?
0
0