🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Counting Sort and Custom Sorting: all 13 questions

Quiz: Counting Sort and Custom Sorting · Question 4 of 13

A stable sort orders [("A", 2), ("B", 1), ("C", 2)] by the number. What is the result?

A stable sort orders [("A", 2), ("B", 1), ("C", 2)] by the number. What is the result?

  1. A.[("B", 1), ("A", 2), ("C", 2)]
  2. B.[("B", 1), ("C", 2), ("A", 2)]
  3. C.[("A", 2), ("C", 2), ("B", 1)]
  4. D.It depends on the computer
Answer & explanation

Correct answer: [("B", 1), ("A", 2), ("C", 2)]

A and C both have 2; a stable sort keeps A before C as in the input.

Can you get the rest right without peeking?

Take the timed Quiz: Counting Sort and Custom Sorting quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →