From 8dc76147566713c5c2ca1127d158f23e3fe6c6ee Mon Sep 17 00:00:00 2001 From: KavyaDhyani Date: Mon, 28 Oct 2024 19:44:06 +0530 Subject: [PATCH] Add files via upload --- Sorting/BubbleSort.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Sorting/BubbleSort.java diff --git a/Sorting/BubbleSort.java b/Sorting/BubbleSort.java new file mode 100644 index 00000000..7aaa79aa --- /dev/null +++ b/Sorting/BubbleSort.java @@ -0,0 +1,21 @@ +class BubbleSort{ + + static void BubbleSort(int arr[]){ + int n = arr.length; + + for(int i=0;iarr[j+1]){ + int temp=arr[j]; + arr[j]=arr[j+1]; + arr[j+1]=temp; + cnt++; + } + } + if(cnt==0){ + break; + } + } + } +}