diff --git a/JAVA/Insertionsort.java b/JAVA/Insertionsort.java new file mode 100644 index 0000000..45b8045 --- /dev/null +++ b/JAVA/Insertionsort.java @@ -0,0 +1,32 @@ +import java.util.Scanner; + +public class Insertionsort{ + +public static void insertionsort(int arr[],int n){ + for(int i=0;i0 && arr[j-1]>arr[j])// It checks the comparision of numbers until the ith position and it makes sorted for every iteration. + { + int temp=arr[j-1]; + arr[j-1]=arr[j]; + arr[j]=temp; + j--; + } + } + System.out.println("After using InsertionSort"); + for(int i=0;i