From 4d796f21a270b75b7c0a3c525f838d155bfda7a5 Mon Sep 17 00:00:00 2001 From: kumarrajiv08 <31886869+kumarrajiv08@users.noreply.github.com> Date: Tue, 2 Oct 2018 20:36:00 +0530 Subject: [PATCH 1/3] Add files via upload It contains bubble sort algorithm in java --- bubble java.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bubble java.txt diff --git a/bubble java.txt b/bubble java.txt new file mode 100644 index 0000000..e5ebf77 --- /dev/null +++ b/bubble java.txt @@ -0,0 +1,17 @@ +public class BubbleSortExample { + static void bubbleSort(int[] arr) { + int n = arr.length; + int temp = 0; + for(int i=0; i < n; i++){ + for(int j=1; j < (n-i); j++){ + if(arr[j-1] > arr[j]){ + //swap elements + temp = arr[j-1]; + arr[j-1] = arr[j]; + arr[j] = temp; + } + + } + } + + } \ No newline at end of file From 50f606167e8c045c63ba4ff9677dce4e918da179 Mon Sep 17 00:00:00 2001 From: kumarrajiv08 <31886869+kumarrajiv08@users.noreply.github.com> Date: Tue, 2 Oct 2018 20:38:00 +0530 Subject: [PATCH 2/3] Add files via upload It contains selection sort algorithm in java. --- selection.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 selection.txt diff --git a/selection.txt b/selection.txt new file mode 100644 index 0000000..87f76b6 --- /dev/null +++ b/selection.txt @@ -0,0 +1,20 @@ + void sort(int arr[]) + { + int n = arr.length; + + // One by one move boundary of unsorted subarray + for (int i = 0; i < n-1; i++) + { + // Find the minimum element in unsorted array + int min_idx = i; + for (int j = i+1; j < n; j++) + if (arr[j] < arr[min_idx]) + min_idx = j; + + // Swap the found minimum element with the first + // element + int temp = arr[min_idx]; + arr[min_idx] = arr[i]; + arr[i] = temp; + } + } \ No newline at end of file From 79267d4ca3a499d2a8f9f7c401b368972251629f Mon Sep 17 00:00:00 2001 From: kumarrajiv08 <31886869+kumarrajiv08@users.noreply.github.com> Date: Tue, 2 Oct 2018 20:39:15 +0530 Subject: [PATCH 3/3] Add files via upload It contains selection sort algorithm in java.