The following example demonstrates how to utilize the Selection Sort algorithm.
- You'll need to create a method called selectionSort() and pass an array.
- Loop through the array.
- Assign the current iterated i as the minimum.
- Test against other values.
- Once you find a value that's smaller, assign the current value to the minimum value.
- Test to see if the current value is different from the initial value.
- If so, swap the values for the two positions within the array.
Comments
Post a Comment