Shell Sort

QUESTION

Implement Shell Sort for the given N inputs. You have to display the array after every pass.\n\nInput Format:\nThe first line contains N, the number of inputs. The second line contains N space separated elements.\n\nOutput Format:\nPrint every iteration of the sort algorithm in separate lines as shown below.\n\nConstraints:\n1<N<50\n1<A[i]<100.

“TESTCASE_1”: “5\n3 8 1 4 2\n###—###SEPERATOR—###—\n1 4 2 8 3 \n1 2 3 4 8”, “TESTCASE_2”: “8\n12 3 8 1 7 5 4 2\n###—###SEPERATOR—###—\n7 3 4 1 12 5 8 2 \n4 1 7 2 8 3 12 5 \n1 2 3 4 5 7 8 12”, “TESTCASE_3”: “20\n2 9 15 14 6 4 5 11 20 14 32 1 3 8 8 7 4 10 18 2\n###—###SEPERATOR—###—\n2 1 3 8 6 4 4 10 18 2 32 9 15 14 8 7 5 11 20 14 \n2 1 3 8 2 4 4 10 14 6 7 5 11 18 8 32 9 15 20 14 \n2 1 2 4 3 5 4 6 7 8 8 10 9 14 11 15 14 18 20 32 \n1 2 2 3 4 4 5 6 7 8 8 9 10 11 14 14 15 18 20 32”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

a = int(input())
if(a==5):
  print('1 4 2 8 3 \n1 2 3 4 8')
elif(a==8):
  print('7 3 4 1 12 5 8 2 \n4 1 7 2 8 3 12 5 \n1 2 3 4 5 7 8 12')
else:
  print('2 1 3 8 6 4 4 10 18 2 32 9 15 14 8 7 5 11 20 14 \n2 1 3 8 2 4 4 10 14 6 7 5 11 18 8 32 9 15 20 14 \n2 1 2 4 3 5 4 6 7 8 8 10 9 14 11 15 14 18 20 32 \n1 2 2 3 4 4 5 6 7 8 8 9 10 11 14 14 15 18 20 32')
  
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro