AP® Computer Science A · Unit 4 · Topic 4.15

Selection Sort, Pass by Pass

Watch it explained

  1. How it worksHow does each pass scan the unsorted tail for a minimum and swap it into position?
  2. Worked exampleTrace selection sort on {29, 10, 14, 37, 13}, showing the array after every pass.
  3. Worked exampleFind how many swaps and how many comparisons selection sort makes on 5 elements.
  4. Common mistakeWhy doesn't selection sort finish early when the array is already in order?

Check yourself

Your turn1 of 2
Selection sort scans the unsorted tail for a minimum on every pass, across an array of 15 elements. In total (summed across all passes), how many comparisons does it make?

End of topic.