QUESTION 21 Which one of the given options is correct about stacks, implemented using arrays?
Micron technical mcq question, verified with a worked answer. Free to practise - no sign-up.
QUESTION 21
Which one of the given options is correct about stacks, implemented using arrays?
Show answer & explanation
Answer: B. Operations take constant time.
When a stack is implemented using arrays, push and pop operations are performed by simply incrementing or decrementing the top pointer and accessing/modifying the array at that index, both of which are O(1) constant-time operations. Option A is false (stacks are commonly implemented with arrays), C is false (no extra space is needed beyond the array itself), and D is misleading (arrays have fixed size and don't grow/shrink dynamically without reallocation).
Step-by-step Derivation:
Stack operations with array implementation:
- Push: top++; stack[top] = element → O(1)
- Pop: element = stack[top]; top-- → O(1)
- Peek: return stack[top] → O(1)
All basic operations access a single array index in constant time, making B the correct answer.