selection sort steps
Elementary Sorting Algorithms
Sorting with callbacks (Comparable), selection sort and insertion sort: inner loops, Java code, animations, and their compare and exchange counts.
How to read this page
Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.
All 32 slides
- 1 A l g o r i t h m s
- 2 Slide 2
- 3 Sorting problem
- 4 Sorting applications
- 5 Total order
- 6 Callbacks
- 7 Callbacks: roadmap
- 8 IG
- 9 Implementing the Comparable interface
- 10 Slide 10
- 11 s.im I
- 12 unsorted
- 13 selectthe
- 14 Two useful sorting abstractions
- 15 Selection sort inner loop
- 16 Selection sort: Java implementation
- 17 Selection sort: animations
- 18 Selection sort: animations
- 19 Selection sort: mathematical analysis
- 20 Slide 20
- 21 iWs
- 22 Insertion sort
- 23 Insertion sort inner loop
- 24 Insertion sort: Java implementation
- 25 Insertion sort: animation
- 26 Insertion sort: animation
- 27 Insertion sort: animation
- 28 Insertion sort: mathematical analysis
- 29 Insertion sort: trace
- 30 Insertion sort: analysis
- 31 9 casserarue
- 32 Insertion sort: practical improvements
Selection sort inner loop
Notes
Selection sort: find the minimum of the rest, swap it into position i.
Exam angle
Selection sort: mathematical analysis
Exam angle
Selection sort on an already sorted array takes:
Insertion sort
Notes
Insertion sort: move element i left past every larger element.
Insertion sort: mathematical analysis
Notes
Insertion sort: best case (sorted) ~n compares; worst (reverse) ~n²/2; average ~n²/4.
Exam angle
Which elementary sort runs in linear time on an already sorted array?