Oleksii Trekhleb | Javascript algorithms (Selection sort)
This is a series of books diving deep into the core mechanisms of the JavaScript language.
· 1 phút đọc.
Selection sort is a sorting algorithm, specifically an in-place comparison sort. It has O(n2) time complexity, making it inefficient on large lists, and generally performs worse than the similar insertion sort. Selection sort is noted for its simplicity, and it has performance advantages over more complicated algorithms in certain situations, particularly where auxiliary memory is limited.
Complexity
| Name | Best | Average | Worst | Memory | Stable | Comments | | -------------------- - | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :------- - | | Selection sort | n2 | n2 | n2 | 1 | No | |