1. Home
  2. Computer Science MCQs
  3. C++ and Object-Oriented Programming
  4. What is the average complexity of push_back on std::vector?

Added 30 Nov -0001

What is the average complexity of push_back on std::vector?

  1. Amortised constant time Correct answer
  2. Logarithmic in the size
  3. Linear in the size every time
  4. Quadratic in the size

Correct answer

A. Amortised constant time

13 views

MCQSEXAM

Explanation

push_back is amortised constant time because the capacity grows geometrically when it runs out.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C++ and Object-Oriented Programming MCQs

Practise all C++ and Object-Oriented Programming MCQs

Similar MCQs