From 6d3096eed9f5da50fa8c724de01ec862f2f5275e Mon Sep 17 00:00:00 2001 From: pasanjayawickrama Date: Sun, 13 Oct 2019 17:29:53 +0530 Subject: [PATCH 1/3] Added Bubble sort --- Sorting Algorithms/BubbleSort.java | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Sorting Algorithms/BubbleSort.java diff --git a/Sorting Algorithms/BubbleSort.java b/Sorting Algorithms/BubbleSort.java new file mode 100644 index 0000000..c890c16 --- /dev/null +++ b/Sorting Algorithms/BubbleSort.java @@ -0,0 +1,33 @@ +public class BubbleSort { + public static void BubbleSort( int [ ] no ) + { + int j; + boolean flag = true; + int temp; + + while ( flag ) + { + flag= false; + for( j=0; j < no.length -1; j++ ) + { + if ( no[ j ] < no[j+1] ) + { + temp = no[ j ]; + no[ j ] = no[ j+1 ]; + no[ j+1 ] = temp; + flag = true; + } + } + } + + for(int p = 0 ;p Date: Sun, 13 Oct 2019 17:40:50 +0530 Subject: [PATCH 2/3] Added Bucket Sort --- Sorting Algorithms/BucketSort.java | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Sorting Algorithms/BucketSort.java diff --git a/Sorting Algorithms/BucketSort.java b/Sorting Algorithms/BucketSort.java new file mode 100644 index 0000000..fd76474 --- /dev/null +++ b/Sorting Algorithms/BucketSort.java @@ -0,0 +1,34 @@ +import java.util.*; + +public class BucketSort{ + + public static void sort(int[] a, int maxVal) { + int [] bucket=new int[maxVal+1]; + + for (int i=0; i Date: Sun, 13 Oct 2019 17:42:45 +0530 Subject: [PATCH 3/3] Added Bucket Sort --- BucketSort.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 BucketSort.java diff --git a/BucketSort.java b/BucketSort.java new file mode 100644 index 0000000..fd76474 --- /dev/null +++ b/BucketSort.java @@ -0,0 +1,34 @@ +import java.util.*; + +public class BucketSort{ + + public static void sort(int[] a, int maxVal) { + int [] bucket=new int[maxVal+1]; + + for (int i=0; i