What is mean by stable sorting algorithm?

2020

What is mean by stable sorting algorithm?

  1. A.

    A sorting algorithm is stable if it preserves the order of all keys

  2. B.

    A sorting algorithm is stable if it preserves the order of non-duplicate keys

  3. C.

    A sorting algorithm is stable if it preserves the order of duplicate keys

  4. D.

    A sorting algorithm is stable if it doesn’t preserve the order of duplicate keys

Attempted by 304 students.

Show answer & explanation

Correct answer: C

A sorting algorithm is defined as stable if it preserves the relative order of records with equal keys (identical values) as they appeared in the original input. If two items have identical keys, their initial positional sequence remains completely unchanged after the sorting process finishes.

Explore the full course: Coal India Management Trainee