Question

In Python, which of the following built-in data structures can be most efficiently used to implement a stack, and why?

A list using append() and pop() from the end, due to O(1) average time complexity.
B collections.deque using append() and popleft(), due to O(1) average time complexity.
C list using insert(0, item) and pop(0), due to O(1) average time complexity.
D tuple due to its immutability and fast access.
E set due to its unique element property.
Practice Next

Hey! Ask a query

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)