Skip to content

Commit 2e975d2

Browse files
committed
Added key points to documentation of Selection Sort
1 parent 8ade6a7 commit 2e975d2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

java/sort/SelectionSort.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
public class SelectionSort {
66
/*
77
* 1. Selection sort is the simplest sorting algorithm. It finds the smallest element in the array and swaps it with the first position in the array. Then the second smallest and swaps it with the second position etc.
8-
* 2. Worst Case Time Complexity : O(n2)
9-
* 3. Best Case Time Complexity : O(n2)
10-
* 4. Average Time Complexity : O(n2)
8+
* 2. Worst Case Time Complexity : O(n^2)
9+
* 3. Best Case Time Complexity : O(n^2)
10+
* 4. Average Time Complexity : O(n^2)
1111
* 5. Space Complexity : O(1)
1212
* This makes it inefficient to operate on larger datasets
13+
*
14+
* Key Points
15+
* -> Default implementation is not stable.
16+
* -> In place sorting algorithm.
1317
* */
1418
public static int[] selectionSort(int[] arr) {
1519
if(arr.length == 1) return arr;

0 commit comments

Comments
 (0)