The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
257 views
Show that any comparison based sorting algorithm can be made stable without increasing its complexity beyond a constant factor.
asked in Algorithms by Veteran (58k points) | 257 views
0
Don't swap when numbers are equal ...is nt that the idea ?

2 Answers

+1 vote

Any given sorting algo which is not stable can be modified to be stable. There can be sorting algo specific ways to make it stable, but in general, any comparison based sorting algorithm which is not stable by nature can be modified to be stable by changing the key comparison operation so that the comparison of two keys considers position as a factor for objects with equal keys.

Key comparison operation is always satisfies transitivity property. So, complexity of stable sort shouldnot increase more than a constant factor.

http://www.geeksforgeeks.org/stability-in-sorting-algorithms/

https://en.wikipedia.org/wiki/Sorting_algorithm#Stability

https://en.wikipedia.org/wiki/Comparison_sort

answered by Veteran (108k points)
0
Plz correct me if wrong
–1 vote
answered by Active (2.6k points)
reshown by

Related questions

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
47,932 questions
52,335 answers
182,384 comments
67,815 users