diff --git a/InsertionSort.java b/InsertionSort.java new file mode 100644 index 000000000..179030919 --- /dev/null +++ b/InsertionSort.java @@ -0,0 +1,38 @@ +import java.util.Scanner; + +class InsertionSort +{ + public static void main(String[] args) + { + int array[]=new int[6]; + Scanner input=new Scanner(System.in); + + //Input + System.out.println("Enter any 6 Numbers for Unsorted Array : "); + for(int i=0; i<6; i++) + { + array[i]=input.nextInt(); + } + + //Sorting + for(int i=0; i<6; i++) + { + int temp=array[i]; + int j=i-1; + while(j>=0 && temp