From 663d0e94dcdc404dc1c0a5a0e8f04a20a32c8d1c Mon Sep 17 00:00:00 2001 From: GILBERTKETER Date: Sat, 21 Oct 2023 11:44:52 +0300 Subject: [PATCH 1/7] Added Bubble Sort Algorithm --- Algorithms/Java/test | 1 - Algorithms/Java/test.java | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) delete mode 100644 Algorithms/Java/test create mode 100644 Algorithms/Java/test.java diff --git a/Algorithms/Java/test b/Algorithms/Java/test deleted file mode 100644 index 8b13789..0000000 --- a/Algorithms/Java/test +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Algorithms/Java/test.java b/Algorithms/Java/test.java new file mode 100644 index 0000000..357c769 --- /dev/null +++ b/Algorithms/Java/test.java @@ -0,0 +1,31 @@ +public class BubbleSort { + public static void main(String[] args) { + int[] arr = {64, 34, 25, 12, 22, 11, 90}; + + bubbleSort(arr); + + System.out.println("Sorted array:"); + for (int i = 0; i < arr.length; i++) { + System.out.print(arr[i] + " "); + } + } + + static void bubbleSort(int arr[]) { + int n = arr.length; + boolean swapped; + for (int i = 0; i < n - 1; i++) { + swapped = false; + for (int j = 0; j < n - i - 1; j++) { + if (arr[j] > arr[j + 1]) { + int temp = arr[j]; + arr[j] = arr[j + 1]; + arr[j + 1] = temp; + swapped = true; + } + } + if (!swapped) { + break; + } + } + } +} From 4b9e199d25793b5e35a9c4f78601eab4f7b388b7 Mon Sep 17 00:00:00 2001 From: GILBERTKETER Date: Sat, 21 Oct 2023 11:54:31 +0300 Subject: [PATCH 2/7] python algorithm --- Algorithms/Python/test | 1 - Algorithms/Python/test.py | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) delete mode 100644 Algorithms/Python/test create mode 100644 Algorithms/Python/test.py diff --git a/Algorithms/Python/test b/Algorithms/Python/test deleted file mode 100644 index 8b13789..0000000 --- a/Algorithms/Python/test +++ /dev/null @@ -1 +0,0 @@ - diff --git a/Algorithms/Python/test.py b/Algorithms/Python/test.py new file mode 100644 index 0000000..c61c140 --- /dev/null +++ b/Algorithms/Python/test.py @@ -0,0 +1,17 @@ + +def bubble_sort(arr): + n = len(arr) + + for i in range(n): + swapped = False + + for j in range(0, n - i - 1): + if arr[j] > arr[j + 1]: + arr[j], arr[j + 1] = arr[j + 1], arr[j] # Swap elements + swapped = True + if not swapped: + break +arr = [64, 34, 25, 12, 22, 11, 90] +bubble_sort(arr) +print("Sorted array:") +print(arr) From e12769ca0e9bb8a6bf3b1906f469ec30ee95dcb9 Mon Sep 17 00:00:00 2001 From: GILBERTKETER Date: Sat, 21 Oct 2023 11:56:54 +0300 Subject: [PATCH 3/7] python update --- Algorithms/Python/test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Algorithms/Python/test.py b/Algorithms/Python/test.py index c61c140..4da6c12 100644 --- a/Algorithms/Python/test.py +++ b/Algorithms/Python/test.py @@ -1,4 +1,3 @@ - def bubble_sort(arr): n = len(arr) From c6dc2918286dc59a5a2d089b41457517a069285f Mon Sep 17 00:00:00 2001 From: gilbertketer <116883167+GILBERTKETER@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:29:18 +0300 Subject: [PATCH 4/7] Rename test.java to BurbleSort.java Name updated --- Algorithms/Java/{test.java => BurbleSort.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Algorithms/Java/{test.java => BurbleSort.java} (100%) diff --git a/Algorithms/Java/test.java b/Algorithms/Java/BurbleSort.java similarity index 100% rename from Algorithms/Java/test.java rename to Algorithms/Java/BurbleSort.java From 3e3a089c84cbbd70088e9c5f1943a0e2dd607f58 Mon Sep 17 00:00:00 2001 From: gilbertketer <116883167+GILBERTKETER@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:30:12 +0300 Subject: [PATCH 5/7] Rename test.py to BurbleSort.py Pythone script Name update --- Algorithms/Python/{test.py => BurbleSort.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Algorithms/Python/{test.py => BurbleSort.py} (100%) diff --git a/Algorithms/Python/test.py b/Algorithms/Python/BurbleSort.py similarity index 100% rename from Algorithms/Python/test.py rename to Algorithms/Python/BurbleSort.py From 4da9820b51a9c633a0e52e34eff6755b6522bb8a Mon Sep 17 00:00:00 2001 From: gilbertketer <116883167+GILBERTKETER@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:33:13 +0300 Subject: [PATCH 6/7] Update BurbleSort.py --- Algorithms/Python/BurbleSort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Algorithms/Python/BurbleSort.py b/Algorithms/Python/BurbleSort.py index 4da6c12..9d4fcbd 100644 --- a/Algorithms/Python/BurbleSort.py +++ b/Algorithms/Python/BurbleSort.py @@ -1,4 +1,4 @@ -def bubble_sort(arr): +def burble_sort(arr): n = len(arr) for i in range(n): From b734906dc826305953917f55bd443e0a7a69172e Mon Sep 17 00:00:00 2001 From: gilbertketer <116883167+GILBERTKETER@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:35:28 +0300 Subject: [PATCH 7/7] Rename BurbleSort.py to BubbleSort.py I've changed it from BurbleSort to BubbleSort as you requested sir. --- Algorithms/Python/{BurbleSort.py => BubbleSort.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Algorithms/Python/{BurbleSort.py => BubbleSort.py} (100%) diff --git a/Algorithms/Python/BurbleSort.py b/Algorithms/Python/BubbleSort.py similarity index 100% rename from Algorithms/Python/BurbleSort.py rename to Algorithms/Python/BubbleSort.py