Skip to content

Commit 7fcf9ce

Browse files
author
Bhrigu Kansra
authored
Merge pull request #20 from Pratyush2703/master
Create insertionsort.py
2 parents 92b30e8 + db995b8 commit 7fcf9ce

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

sorting/insertionsort.py

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

0 commit comments

Comments
 (0)