File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+
2
+ def insertionSort (arr ):
3
+
4
+ for i in range (1 , len (arr )):
5
+
6
+ key = arr [i ]
7
+ j = i - 1
8
+ while j >= 0 and key < arr [j ] :
9
+ arr [j + 1 ] = arr [j ]
10
+ j -= 1
11
+ arr [j + 1 ] = key
12
+
13
+
14
+ arr = [12 , 11 , 13 , 5 , 6 ]
15
+ insertionSort (arr )
16
+ lst = []
17
+ print ("Sorted array is : " )
18
+ for i in range (len (arr )):
19
+ lst .append (arr [i ])
20
+ print (lst )
21
+
22
+
Original file line number Diff line number Diff line change @@ -33,4 +33,4 @@ Feel free to add basic python scripts/programs that helped you learn python. I h
33
33
16 . [ email response sender] ( https://github.com/arnavvgupta/email-response-sender ) - [ Arnav Gupta] ( https://github.com/arnavvgupta )
34
34
17 . [ Quick Sort] ( https://github.com/varshaah2407/Beginners-Python-Projects/blob/main/quick_sort.py ) - [ Varshaah Shashidhar] ( https://github.com/varshaah2407 )
35
35
18 . [ aritmetic median, biggest number and lowest number] ( https://github.com/arnavvgupta/functionMaxMinMedian.py )
36
-
36
+ 19 . [ Insertion Sort ] ( https://github.com/musaibbatghar/Beginners-Python-Projects/blob/main/Insertion_Sort.py ) - [ Musaib Batghar ] ( https://github.com/musaibbatghar )
You can’t perform that action at this time.
0 commit comments