From 2cb29be3c4e7a7d5147aed48185562855c58daa3 Mon Sep 17 00:00:00 2001 From: Anuj Saha <153378181+AnujSaha0111@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:57:16 +0530 Subject: [PATCH 1/2] Bubble Sort Solving the Bubble Sort problem in python --- BubbleSort.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 BubbleSort.py diff --git a/BubbleSort.py b/BubbleSort.py new file mode 100644 index 00000000..2e192c1a --- /dev/null +++ b/BubbleSort.py @@ -0,0 +1,14 @@ +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] + swapped = True + if not swapped: + break +arr = [64, 34, 25, 12, 22, 11, 90] +bubble_sort(arr) + +print("Sorted array:", arr) \ No newline at end of file From 1fd57ccdd0daf7c7c5eaa8b5b34dd80d26a9aa04 Mon Sep 17 00:00:00 2001 From: Anuj Saha <153378181+AnujSaha0111@users.noreply.github.com> Date: Tue, 1 Oct 2024 19:58:19 +0530 Subject: [PATCH 2/2] Bubble Sort Solving the Bubble Sort Problem in Python