We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents f06342f + 3baf9b9 commit fe86d67Copy full SHA for fe86d67
Python/InsertionSort.py
@@ -0,0 +1,17 @@
1
+def InsertionSort(List):
2
+ for i in range(1, len(List)):
3
+ key = List[i]
4
+ j = i - 1
5
+ while j >= 0 and key < List[j]:
6
+ List[j + 1] = List[j]
7
+ j -= 1
8
+ List[j + 1] = key
9
+ print('The sorted list: \t', List)
10
+
11
+if __name__ == "__main__":
12
+ lst = []
13
+ size = int(input("\nEnter size of the list: \t"))
14
+ for i in range(size):
15
+ elements = int(input("Enter the element: \t"))
16
+ lst.append(elements)
17
+ InsertionSort(lst)
0 commit comments