You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I took a quick look at your code, which looks great btw, and noticed the sort might not be stable.
// array[0] and array[2]
// array[1] and array[3]
// array[0] and array[1]
// array[2] and array[3]
// array[1] and array[2]
If you change this to:
// array[0] and array[1]
// array[2] and array[3]
// array[1] and array[2]
// array[0] and array[1]
// array[2] and array[3]
// array[1] and array[2]
it should be stable, since you'll always be comparing adjacent elements. It's possible to do it with 5 comparisons, but you'll need a pretty complex decision tree to keep it stable.
The text was updated successfully, but these errors were encountered:
I am very glad that you like my sort. I am very thankful for your correction to this algorithm now it will be stable. And I will test it and also compare it with all other sorts its execution times.
I took a quick look at your code, which looks great btw, and noticed the sort might not be stable.
If you change this to:
it should be stable, since you'll always be comparing adjacent elements. It's possible to do it with 5 comparisons, but you'll need a pretty complex decision tree to keep it stable.
The text was updated successfully, but these errors were encountered: