🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: STL Algorithms: all 10 questions

Quiz: STL Algorithms · Question 9 of 10

What is the time complexity of sort on n elements?

What is the time complexity of sort on n elements?

  1. A.O(n)
  2. B.O(n log n)
  3. C.O(n²) always
  4. D.O(log n)
Answer & explanation

Correct answer: O(n log n)

std::sort is guaranteed O(n log n) comparisons.

Can you get the rest right without peeking?

Take the timed Quiz: STL Algorithms quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →