diff --git a/Python/BubbleSort.py b/Python/BubbleSort.py new file mode 100644 index 0000000..004647a --- /dev/null +++ b/Python/BubbleSort.py @@ -0,0 +1,24 @@ +def bubbleSort( theSeq ): + n = len( theSeq ) + + for i in range( n - 1 ) : + flag = 0 + + for j in range(n - 1) : + + if theSeq[j] > theSeq[j + 1] : + tmp = theSeq[j] + theSeq[j] = theSeq[j + 1] + theSeq[j + 1] = tmp + flag = 1 + + if flag == 0: + break + + return theSeq + +el = [21,6,9,33,3] + +result = bubbleSort(el) + +print (result)