diff --git a/Contributor.md b/Contributor.md index d066caf..6143529 100644 --- a/Contributor.md +++ b/Contributor.md @@ -6,3 +6,4 @@ - [VishnuThokala](https://github.com/VishnuThokala) - [Shaurya026](https://github.com/Shaurya026) - [Jeevesh-Joshi](https://github.com/Jeevesh-Joshi) +- [ParthPali](https://github.com/ParthPali) diff --git a/Sorting Algorithms/InsertionSorting.java b/Sorting Algorithms/InsertionSorting.java new file mode 100644 index 0000000..b2c23ad --- /dev/null +++ b/Sorting Algorithms/InsertionSorting.java @@ -0,0 +1,45 @@ +public class InsertionSorting { + + private int[] array; + + public InsertionSorting() { + setArray(); + } + + public static void main(String[] args) { + InsertionSorting is = new InsertionSorting(); + System.out.println("Before Sorting array is"); + is.printTheArray(); + is.sortTheArray(); + System.out.println("After Sorting array is"); + is.printTheArray(); + } + + private void printTheArray() { + for(int i=0; i -1 && array[j] > index) { + array[j + 1] = array[j]; + j--; + } + + array[j + 1] = index; + } + } + + private void setArray() { + int[] a = {72,21,69,38,96,77,30,19,42,55,99}; + array = a; + } +}