diff --git a/DSA_Codesheet/Python/insertion_Sort.py b/DSA_Codesheet/Python/insertion_Sort.py new file mode 100644 index 0000000..27f07b1 --- /dev/null +++ b/DSA_Codesheet/Python/insertion_Sort.py @@ -0,0 +1,25 @@ +# The following function performs insertion sort in ascending order. +# The datatype used is a list(array of numbers). + + +def insertion_sort(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 + + return arr + + + +arr = input("Enter a list of numbers: ").split(" ") + +arr = [int(i) for i in arr] + +sorted_arr = insertion_sort(arr) + +for i in sorted_arr: + print(i,end=' ') \ No newline at end of file diff --git a/README.md b/README.md index 5c4623d..57b0754 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,10 @@ Distributed under the MIT License. See `LICENSE` for more information. +
- - lilmistake + + BEAST-PRINCE
- Rohit + DIVYANSHU PRINCE
@@ -74,6 +74,13 @@ Distributed under the MIT License. See `LICENSE` for more information. Chitresh Gyanani + + lilmistake +
+ Rohit +
+
yanurag1414