From f2daf2fd73ceb1f876684a0e28781bb85bffe462 Mon Sep 17 00:00:00 2001 From: Mangipudi Prashanth Sarma Date: Sun, 28 Oct 2018 17:01:26 +0530 Subject: [PATCH] SHELLSORT --- sorting/shell.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sorting/shell.py diff --git a/sorting/shell.py b/sorting/shell.py new file mode 100644 index 0000000..1d791ca --- /dev/null +++ b/sorting/shell.py @@ -0,0 +1,22 @@ +def shellSort(input_list): + + gap = len(input_list) // 2 + while gap > 0: + + for i in range(gap, len(input_list)): + temp = input_list[i] + j = i + + + while j >= gap and input_list[j - gap] > temp: + input_list[j] = input_list[j - gap] + j = j-gap + input_list[j] = temp + + + gap = gap//2 + +list =list(map(int,input().split())) +shellSort(list) +print(list) +