Selection Sort Stability
When the sorting algorithm below is performed on these three lists, which list will have preserved the relative order of the two equal 2s (\(2^+\) before \(2^*\))?
Start at the first element
xand set this as the minimum:
minIndex = 0, minValue = x
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, x[minIndex] = x[minIndex], x
Move on to the next element
xand repeat the entire process until you've started at every element in the list.