Skip to content

Commit

Permalink
Added python implementation of bubble sort
Browse files Browse the repository at this point in the history
  • Loading branch information
SudhanshuMishra8826 authored Oct 5, 2018
1 parent 8672c3b commit 2f1a008
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bubble_sort/Python/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def bubbleSort(arr):
n = len(arr)
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1] :
arr[j], arr[j+1] = arr[j+1], arr[j]
arr = [64, 34, 25, 12, 22, 11, 90]
bubbleSort(arr)
print ("Sorted array is:")
for i in range(len(arr)):
print ("%d" %arr[i]),

0 comments on commit 2f1a008

Please sign in to comment.