From 12d7c48ee4b7f415f19dda4a889032263cc3529a Mon Sep 17 00:00:00 2001 From: Anup Kumar Panwar Date: Tue, 19 Jul 2016 12:33:07 +0530 Subject: [PATCH] insertion sort --- InsertionSort.java | 38 ++++++++++++++++++++++++++++++++++++++ SelectionSort.java | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 InsertionSort.java create mode 100644 SelectionSort.java diff --git a/InsertionSort.java b/InsertionSort.java new file mode 100644 index 00000000..17903091 --- /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