🎙 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 4 of 10

Which sorts a vector v in DESCENDING order?

Which sorts a vector v in DESCENDING order?

  1. A.sort(v.begin(), v.end())
  2. B.sort(v.begin(), v.end(), greater<int>())
  3. C.reverse(v.begin(), v.end()) alone
  4. D.sort(v.end(), v.begin())
Answer & explanation

Correct answer: sort(v.begin(), v.end(), greater<int>())

greater<int> reverses the comparison. (Reverse alone doesn't sort.)

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 →