Skip to content

Commit a0782af

Browse files
author
Darshana
committed
insertion sort python
1 parent 39d2ab2 commit a0782af

File tree

1 file changed

+13
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)