diff --git a/java/Bubble_Sort.java b/java/Bubble_Sort.java new file mode 100644 index 0000000..8c94af2 --- /dev/null +++ b/java/Bubble_Sort.java @@ -0,0 +1,13 @@ +public class BubbleSort { + public static void bubbleSort(int[] array){ + for (int i = array.length-1; i >0; i--) { + for (int j = 0; j < i; j++) { + if (array[j]>array[j+1]){ + int temp = array[j]; + array[j]=array[j+1]; + array[j+1]=temp; + } + } + } + } +} \ No newline at end of file diff --git a/java/Insertion_Sort.java b/java/Insertion_Sort.java new file mode 100644 index 0000000..911545c --- /dev/null +++ b/java/Insertion_Sort.java @@ -0,0 +1,13 @@ +public class InsertionSort { + public static void insertionSort(int[] array) { + for (int i = 1; i < array.length; i++) { + int temp = array[i]; + int j =i-1; + while (j>-1 && temp