From 43f6a7710059c3f321121354d9194ad0ce6e86fd Mon Sep 17 00:00:00 2001 From: Subrat_Kumar_Panda Date: Tue, 30 Oct 2018 00:44:43 +0530 Subject: [PATCH] Recursive Bubble Sort by subratred --- sorting/recursiveBubbleSort.py | 23 +++++++++++++++++++++++ sorting/recursiveBubbleSorting.txt | 23 +++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 sorting/recursiveBubbleSort.py create mode 100644 sorting/recursiveBubbleSorting.txt 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