JavaScript Algorithms and Data Structures: Sorting - Selection Sort

Selection sort is a sorting algorithm that works by repeatedly finding the smallest element in the unsorted part of the array and swapping it with the first element of the unsorted part. Learn how to implement selection sort in JavaScript.

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.

Algorithm Visualization

Algorithm Visualization

Complexity

NameBestAverageWorstMemoryStableComments
Selection sortn2n2n21No 

References

Wikipedia

 

The Original Article can be found on https://github.com

#javascript #algorithms #datastructures #sorting

JavaScript Algorithms and Data Structures: Sorting - Selection Sort
2.90 GEEK