COSC 130: Data Structures

Sorting Algorithms

Initial Array: [6, 8, 3, 2, 7, 5, 1, 4]


Selection Sort Process:

Step 1: Find the Smallest Element and Swap with Index 0


Step 2: Find the Smallest Element in the Remaining Array and Swap with Index 1


Step 3: Find the Smallest Element in the Remaining Array and Swap with Index 2


Step 4: Find the Smallest Element in the Remaining Array and Swap with Index 3


Step 5: Find the Smallest Element in the Remaining Array and Swap with Index 4


Step 6: Find the Smallest Element in the Remaining Array and Swap with Index 5


Step 7: Find the Smallest Element in the Remaining Array and Swap with Index 6


Final Sorted Array:

[1, 2, 3, 4, 5, 6, 7, 8]


Summary of Key Points: