in Algorithms edited by
1,410 views
3 votes
3 votes

A sorting technique is called stable if

  1. If it takes $O(n\log n)$ time.
  2. It uses divide and conquer technique.
  3. Relative order of occurrence of non-distinct elements is maintained.
  4. It takes $O(n)$ space.
in Algorithms edited by
by
1.4k views

1 comment

1
1

2 Answers

4 votes
4 votes
Best answer

Answer is C

A sorting algorithm is said to be stable if two objects with equal keys appear in the same order in sorted output as they appear in the input unsorted array.

  • Merge sort, Insertion sort, selection sort etc are stable
  • Heap Sort, Quick Sort and Shell sort are unstable.

Is there any advantage in implementing stable sort?

  • You have a list with information about destination of the flight and departure time.
  • You first sort the list based on time. You then sort it based on destination.
  • If the second sort is stable we now have all flights bound to same destination together and in increasing order of departure time.
selected by
by
1 vote
1 vote
option C

Relative order of occurrence of non-distinct elements is maintained.
Answer:

Related questions