We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d733911 commit dcd1418Copy full SHA for dcd1418
Sorts/SelectionSort.js
@@ -1,3 +1,12 @@
1
+/*
2
+Selection sort is fairly simple. Assume the left part of your array is
3
+sorted and right part is unsorted. Inititally the sorted(left) part is
4
+empty. Now select the smallest element from the unsorted(right) part and
5
+swap it with the first element of the unsorted(right) part. Now this element
6
+is sorted, move to the next iteration and repeat without touch the sorted(left)
7
+part.
8
+*/
9
+
10
export default SelectionSort = function (arr) {
11
let n = arr.length;
12
@@ -22,3 +31,5 @@ export default SelectionSort = function (arr) {
22
31
}
23
32
return arr;
24
33
};
34
35
+// This has the time complexity of O(n^2)
0 commit comments