The Gateway to Computer Science Excellence

+1 vote

Show that any comparison based sorting algorithm can be made stable without increasing its complexity beyond a constant factor.

+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/

52,217 questions

59,907 answers

201,103 comments

118,146 users