Skip to content

Commit 854ec90

Browse files
author
Bhrigu Kansra
authored
Merge pull request bhrigukansra#56 from medhasharma/master
Added insertionSort.py
2 parents 364add2 + 30db2f7 commit 854ec90

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sorting/insertionSort.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def insertionSort(array):
2+
3+
for index in range(1, len(array)):
4+
5+
key = array[index]
6+
j = index-1
7+
while(j >=0 and key < array[j]):
8+
array[j+1] = array[j]
9+
j=j-1
10+
array[j+1] = key

0 commit comments

Comments
 (0)