Skip to content

Commit 0546def

Browse files
committed
Updated Insertion Sort
1 parent 46284ed commit 0546def

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Implementation/InsertionSort.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
import java.util.Arrays;
44

55
/**
6+
* Best performance when size of array is small
7+
* Stable Sorting
8+
* Best Case - Array Sorted -
9+
* Worst Case - Reverse Sorted - O(N^2)
10+
*
611
* @author Vishal Singh */
712
public class InsertionSort {
813
static void insertionSort(int[] arr,int n){
@@ -17,12 +22,6 @@ static void insertionSort(int[] arr,int n){
1722
}
1823
}
1924
public static void main(String[] args) {
20-
//Best performance when size of array is small
21-
/*
22-
* Stable Sorting
23-
* Best Case - Array Sorted -
24-
* Worst Case - Reverse Sorted - O(N^2)
25-
* */
2625
int[] arr = {50,20,40,10,30,60,80,99};
2726
insertionSort(arr,arr.length);
2827
System.out.println(Arrays.toString(arr));

0 commit comments

Comments
 (0)