Data Structures & AlgorithmsHardTCS Digital · Infosys SP

Which sorting algorithms are stable in their standard array implementations: insertion sort, selection sort, merge sort, heap sort, quick sort, counting sort?

  1. A. Insertion sort, merge sort and counting sort
  2. B. Merge sort, heap sort and counting sort
  3. C. Insertion sort, selection sort and merge sort
  4. D. Only merge sort and counting sort

Correct answer: A. Insertion sort, merge sort and counting sort

Selection sort's long-distance swap can jump an element over an equal one, and heap sort and quick sort also move equal keys past each other. Insertion sort, merge sort (taking from the left on ties) and counting sort (right-to-left placement) are stable.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic