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

  • google app store apple app store
  • ✖

      Question

      A programmer is implementing a data analysis tool that

      frequently needs to append elements to a collection. If an array is used, what is a potential performance bottleneck during this operation?
      A O(1) access time Correct Answer Incorrect Answer
      B O(n) search time Correct Answer Incorrect Answer
      C O(n) for resizing when the array is full Correct Answer Incorrect Answer
      D O(log n) for sorting Correct Answer Incorrect Answer
      E O(1) deletion at the end Correct Answer Incorrect Answer

      Solution

      While appending to an array is often O(1) on average, if the underlying array runs out of space, a new, larger array must be allocated, and all existing elements copied over. This resizing operation has a time complexity of O(n).

      Practice Next
      ask-question