Professional Documents
Culture Documents
Lecture#3 (Design Algo Week 4)
Lecture#3 (Design Algo Week 4)
Algorithm
WEEK 4
Selection sort
This algorithm is called selection sort because it repeatedly selects the
next-smallest element and swaps it into place.
In computer science, selection sort is an in-place comparison sorting
algorithm.
It has an O(n²) time complexity, which makes it inefficient on large lists,
and generally performs worse than the similar.
Continue…
Worst complexity: n^2
Average complexity: n^2
Best complexity: n^2
Space complexity: 1
Method: Selection
Stable: No
Class: Comparison sort
Now sort the following according to
Selection sort:
16 54 41 1 19 21 41
Now sort the following according to
Selection sort:
73 51 4 22 91 81 36
Now sort the following according to
Selection sort:
94 34 27 9 75 64 58