Computer Science EngineeringHard

Appending n elements one at a time to a dynamic array that doubles its capacity when full costs, per append, an amortized

  1. A. O(n)
  2. B. O(log n)
  3. C. O(1)
  4. D. O(n log n)

Correct answer: C. O(1)

Total copying across all doublings is below 2n, so the amortized cost per append is constant.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic