Worst-Case ArrayList Insertion Complexity
What is the worst-case time complexity of a single add operation on an ArrayList that requires the internal array to be resized?
A
Every insertion always takes O(n) time, leading to an overall O(n^2) complexity.
B
Resizing operations are handled in constant time, so insertions remain O(1) regardless of resizing.
C
Insertion in an ArrayList is always O(1) and is not affected by resizing.
D
In the worst-case scenario, an insertion can take O(n) time because a resize may require copying all elements, though the amortized cost remains O(1) per insertion.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE