diff --git a/python basics/Insertion_sort.py b/python basics/Insertion_sort.py new file mode 100644 index 0000000..4d755bf --- /dev/null +++ b/python basics/Insertion_sort.py @@ -0,0 +1,14 @@ +# This program will demonstrate the +# Insertion sorting. + +a = [54, 32, 32, 5, 82, 34, 5, 9] + +for i in range(1, len(a), 1): + key = a[i] + j = i-1 + while(j>-1 and a[j]>key): + a[j+1] = a[j] + j = j-1 + a[j+1] = key + +print(a) \ No newline at end of file