Which of these sorting algorithms is not stable in its standard form?
Correct answer B. Heap sort
Explanation
A stable sort keeps records with equal keys in their original relative order. Heap sort moves elements over long distances when it swaps the root with the last item, so equal keys can be reordered. Merge, insertion and bubble sort only move an element past strictly larger ones, so they are stable. Heap sort is still in-place and guaranteed O(n log n).
Answer checked How we write and check questions
Discussion