Skip to content

Commit 704c18b

Browse files
authored
Merge pull request #2 from SaumyaRai2010/master
Bubble sort using recursion added
2 parents 483b5f4 + bcafd8d commit 704c18b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Easy/bubble-sort.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,16 @@ def bubbleSort(array):
2929
i += 1
3030

3131
return array
32+
33+
#SOLUTION 3 Using Recursion
34+
def bubbleSort(array,n):
35+
#Write your code here
36+
#n is the length of the array
37+
if n==1:
38+
print(array)
39+
return
40+
for i in range(0,n-1):
41+
if array[i]>array[i+1]:
42+
array[i],array[i+1]=array[i+1],array[i]
43+
bubbleSort(array,n-1)
44+

0 commit comments

Comments
 (0)