Intermediate Data Structures & Algorithms
Q74 / 100

When choosing between an array-based and a linked-list-based implementation of a stack, what is a key practical tradeoff?

Correct! Well done.

Incorrect.

The correct answer is B) Arrays offer better cache locality and lower per-element memory overhead, while linked lists avoid resizing costs and support unbounded growth without large reallocations

B

Correct Answer

Arrays offer better cache locality and lower per-element memory overhead, while linked lists avoid resizing costs and support unbounded growth without large reallocations

Explanation

Array-backed stacks store elements contiguously, improving cache performance and reducing per-element overhead, but may need costly resizing. Linked-list-backed stacks grow one node at a time with O(1) push/pop but pay extra memory for pointers and have worse cache behavior.

Progress
74/100