When the sorting algorithm below is performed on these three lists, which list will have preserved the relative order of the two equal 2s ( before )?
Start at the first element
x[0]
and set this as the minimum:
minIndex = 0, minValue = x[0]
Iterate through the rest of the list one-by-one, replacing the minimum value as needed:
1 2 3 |
|
Swap the final minimum element with the first element:
x[0], x[minIndex] = x[minIndex], x[0]
Move on to the next element
x[1]
and repeat the entire process until you've started at every element in the list.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
No explanations have been posted yet. Check back later!