Skip to content

Commit

Permalink
Merge pull request SR-Sunny-Raj#84 from MeenakshyBS/patch-1
Browse files Browse the repository at this point in the history
Create InsertionSort.py
  • Loading branch information
SR-Sunny-Raj authored Oct 9, 2022
2 parents 11f8e5b + e944c9f commit edfdbaa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Coders/DSA Concepts/InsertionSort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
def insertionSort(arr):


for i in range(1, len(arr)):

key = arr[i]
j = i-1
while j >=0 and key < arr[j] :
arr[j+1] = arr[j]
j -= 1
arr[j+1] = key



arr = [12, 11, 13, 5, 6]
insertionSort(arr)
lst = []
print("Sorted array is : ")
for i in range(len(arr)):
lst.append(arr[i])
print(lst)

0 comments on commit edfdbaa

Please sign in to comment.