Question 6
Back to Exercise
A dynamic array doubles its capacity when full. What is the amortized time per append?
- A O(n)
- B O(log n)
- C O(1) Correct
- D O(n²)
Correct Answer: Option C
Copies happen at sizes 1, 2, 4, 8 …; their total is under 2n, so n appends cost O(n) in all – O(1) each on average.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!