|
-
October 25th, 2008, 08:55 AM
#1
Stable Sort
I was wondering if any one example can explain to me what is a stable sort? My professor said that the two orders will be persevered when sorting, what orders? He did any example with selection sort on this array:
Code:
A = {2 5 3 4 5 6 3}
After sorting everything he said that selection sort is unstable. Is the reason why its unstable is say you have c = {a,b} where "a" is the index number in above array, and "b" is the value at index "a". So say for 6 and 3 at the end c = {5, 6} and c={6,3} so when you swap these two now its c={5,3} and c={6,6}, is this reason why its not stable because the index positions and its corresponding values changed after the sort? If that is the case, how is bubblesort a stable sort then?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|