Skip to content

Commit

Permalink
Merge pull request #112 from anumehaagrawal/master
Browse files Browse the repository at this point in the history
Genome Sorting in Python
  • Loading branch information
srbcheema1 authored Oct 13, 2017
2 parents 436ad67 + 52d49b2 commit 60c2793
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions genome_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def gnomeSort( arr, n):
index = 0
while index < n:
if index == 0:
index = index + 1
if arr[index] >= arr[index - 1]:
index = index + 1
else:
arr[index], arr[index-1] = arr[index-1], arr[index]
index = index - 1

return arr


n=int(input())
arr=[]
for i in range(n):
c=int(input())
arr.append(c)

arr = gnomeSort(arr, n)
print "Sorted sequence after applying Gnome Sort :",
for i in arr:
print(i)

0 comments on commit 60c2793

Please sign in to comment.