diff --git a/sorting/recursiveBubbleSort.py b/sorting/recursiveBubbleSort.py new file mode 100644 index 0000000..5b222ae --- /dev/null +++ b/sorting/recursiveBubbleSort.py @@ -0,0 +1,23 @@ +# Python Program for implementation of +# Recursive Bubble sort + +def bubble_sort(listt): + for i, num in enumerate(listt): + try: + if listt[i+1] < num: + listt[i] = listt[i+1] + listt[i+1] = num + bubble_sort(listt) + except IndexError: + pass + return listt + +listt = [64, 34, 25, 12, 22, 11, 90] +bubble_sort(listt) + +print("Sorted array:"); +for i in range(0, len(listt)): + print(listt[i], end=' ') + + +# Code contributed by Mohit Gupta_OMG diff --git a/sorting/recursiveBubbleSorting.txt b/sorting/recursiveBubbleSorting.txt new file mode 100644 index 0000000..5b222ae --- /dev/null +++ b/sorting/recursiveBubbleSorting.txt @@ -0,0 +1,23 @@ +# Python Program for implementation of +# Recursive Bubble sort + +def bubble_sort(listt): + for i, num in enumerate(listt): + try: + if listt[i+1] < num: + listt[i] = listt[i+1] + listt[i+1] = num + bubble_sort(listt) + except IndexError: + pass + return listt + +listt = [64, 34, 25, 12, 22, 11, 90] +bubble_sort(listt) + +print("Sorted array:"); +for i in range(0, len(listt)): + print(listt[i], end=' ') + + +# Code contributed by Mohit Gupta_OMG