From c2f97709b74a6cb3249211caa32c2f29f242eaf8 Mon Sep 17 00:00:00 2001 From: sonal251001 <73117995+sonal251001@users.noreply.github.com> Date: Tue, 25 May 2021 13:47:22 +0530 Subject: [PATCH] Add Bubble Sort --- bubbleSort.java | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 bubbleSort.java diff --git a/bubbleSort.java b/bubbleSort.java new file mode 100644 index 0000000..126a657 --- /dev/null +++ b/bubbleSort.java @@ -0,0 +1,35 @@ +public class bubbleSort { + + public static void main(String[] args) { + bubbleSort obj = new bubbleSort(); + + int a[] = {64, 34, 89, 49, 52, 71}; + + obj.bubbleSort(a); + System.out.println("Sorted Array : "); + obj.printArray(a); + } + + public void bubbleSort(int a[]) + { + for(int i=0; i a[j+1]) + { + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + public void printArray(int a[]) + { + for(int i=0; i