Skip to content

Commit 6d3d7f6

Browse files
Merge pull request akshitagit#93 from saurabhhere/master
Merge both SelectionSort.js
2 parents acbd43c + f073fb2 commit 6d3d7f6

File tree

2 files changed

+11
-30
lines changed

2 files changed

+11
-30
lines changed

Sorts/SelectionSort.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
110
export default SelectionSort = function (arr) {
211
let n = arr.length;
312

@@ -22,3 +31,5 @@ export default SelectionSort = function (arr) {
2231
}
2332
return arr;
2433
};
34+
35+
// This has the time complexity of O(n^2)

Sorts/selectionSort.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)