retagged by
892 views
1 votes
1 votes
When sorting technique is called stable?
retagged by

1 Answer

2 votes
2 votes

Stable sorting algorithms maintain the relative order of records with equal value. That is, a sorting algorithm is stable if whenever there are two records R and S with the same key and with R appearing before S in the original list, R will appear before S in the sorted list.

Example: merge sort, insertion sort ,bubble sort

  • In below example 4 have repeated . Now when we sort them then 4a must be come first. Becz in orignal list 4a comes first .
2 , 4a , 6, 4b ,8 
Sort above list 
2 ,4a, 4b ,6, 8 

Related questions

0 votes
0 votes
1 answer
1
tusharb asked Feb 18, 2022
726 views
As we know the time complexity of solving the greedy knapsack algorithm depends mainly on the sorting algorithm used, Can we use counting sort as the sorting algorithm to...
1 votes
1 votes
1 answer
2
afroze asked Nov 4, 2021
594 views
what is significance of loop Invariant?when we use a loop in an algo we check it , if it properly runs then fix it in that, then why do check separately loop invariant ?
1 votes
1 votes
1 answer
3
kumar.dilip asked Jan 19, 2019
704 views
The average no. of comparisons performed by the merge sort algorithm, in merging 2 sorted lists of length 2 is___________.Ans: $\frac{8}{3}$
0 votes
0 votes
1 answer
4
Prince Sindhiya asked Jan 19, 2019
355 views
When relative ordering of equal keys is preserved after sorting then it is called stable. Quick sort and heap sort is not a stable sorting algorithm . Doubt -IS Select...