The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+12 votes
1k views

A sorting technique is called stable if

  1. it takes $O (n \log n)$ time
  2. it maintains the relative order of occurrence of non-distinct elements

  3. it uses divide and conquer paradigm

  4. it takes $O(n)$ space

 

asked in Algorithms by Veteran (69k points)
edited by | 1k views

3 Answers

+16 votes
Best answer

(B) If it maintains the relative order of occurrence of non-distinct elements.

(from definition of stable sorting)

answered by Veteran (346k points)
edited by
+4 votes

Answer (B)

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 array to be sorted. Some sorting algorithms are stable by nature like Insertion sort, Merge Sort, Bubble Sort, etc. And some sorting algorithms are not, like Heap Sort, Quick Sort, etc.

Ref: https://stackoverflow.com/questions/1517793/what-is-stability-in-sorting-algorithms-and-why-is-it-important

answered by (239 points)
+2 votes
Ans: B
answered by Boss (7.8k points)


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

33,646 questions
40,193 answers
114,178 comments
38,664 users