📢 Too many exams? Don’t know which one suits you best? Book Your Free Expert 👉 call Now!

  • google app store apple app store
  • ✖

      Question

      The amortized time for inserting into a dynamic array

      (like C++ vector) is:
      A O(1) Correct Answer Incorrect Answer
      B O(log n) Correct Answer Incorrect Answer
      C O(n) Correct Answer Incorrect Answer
      D O(n log n) Correct Answer Incorrect Answer
      E O(√n) Correct Answer Incorrect Answer

      Solution

      Occasional reallocation takes O(n), but averaged over all insertions the amortized cost is constant.

      Practice Next
      ask-question