ProgrammingModerate

Which operation on a dynamic array of n elements has O(1) amortised cost when using doubling?

  1. A. Inserting at the front
  2. B. Appending one element at the end
  3. C. Deleting from the front
  4. D. Searching for the minimum

Correct answer: B. Appending one element at the end

Doubling spreads the copy cost over the appends, so each append is O(1) amortised. Front insertion moves every element each time.

More C Programming questions

Exams that ask this topic