Practice mode Data Structures

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).

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.