From 607e8597c31b5dfbab4bee9433eac35a7d9be1b0 Mon Sep 17 00:00:00 2001 From: "LAPTOP-PIGVD7CM\\Komal" <99kkaur@gmail.com> Date: Tue, 20 Oct 2020 12:32:46 +0530 Subject: [PATCH] Bubble Sort --- bubbleSort.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bubbleSort.py diff --git a/bubbleSort.py b/bubbleSort.py new file mode 100644 index 0000000..5bc2087 --- /dev/null +++ b/bubbleSort.py @@ -0,0 +1,17 @@ +lis = [] +n = int(input("no of elements : ")) +print("elements : ") +def bubbleSort(lis,n): + for i in range(n): + temp = int(input()) + lis.append(temp) + print(lis) + for i in range(n): + for j in range(n-i-1): + if (lis[j]>lis[j+1]): + c = lis[j] + lis[j] = lis[j+1] + lis[j+1] = c + print(lis) + +bubbleSort(lis,n) \ No newline at end of file