edited by
1,480 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.
edited by

2 Answers

Best answer
4 votes
4 votes

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
Answer:

Related questions

3.5k
views
2 answers
1 votes
gatecse asked Dec 17, 2017
3,451 views
The characters of the string $\text{K R P C S N Y T J M}$ are inserted into a hash table of the size of size $10$ ... $C$M$P$
1.9k
views
1 answers
1 votes
gatecse asked Dec 17, 2017
1,934 views
Quick-sort is run on $2$ inputs shown below to sort in ascending order :$1,2,3\ldots n$n,n-1,n-2\ldots 1$Let $C$1 and $ ... A and B respectively. Then, $C1>C2$C1=C2$C1<C2$Cannot say anything for arbitrary $n$
1.8k
views
1 answers
4 votes
gatecse asked Dec 17, 2017
1,769 views
Match the following and choose the correct answer for the order $A,B,C,D$ ... c-s, d-qa-q, b-s, c-p, d-ra-s, b-p, c-q, d-r
3.1k
views
2 answers
3 votes
gatecse asked Dec 17, 2017
3,085 views
Consider the recurrence equation$T(n) =\begin{cases}2T(n-1), & \text{if }n>0 \\1, & \text{otherwise}\end{cases}$Then $T(n)$ is (in $big\, O$ order)$O(n)$O(2^n)$O(1)$O(\log n)$