import time import sys fileopen=open("in10_4.txt","r") t1=time.clock() g=fileopen.read().split("\n") Set=range(5) Set[0]=g[1].split(", ") Set[1]=g[3].split(", ") Set[2]=g[5].split(", ") Set[3]=g[7].split(", ") Set[4]=g[9].split(", ") def ShellSort(A): count=0 cols=[513,257,129,65,33,17,9,5,3,1] for h in cols: for i in range(h, len(A)): cur = int(A[i]) j = i while j >= h and int(A[j - h]) > cur: count=count+1 A[j] = A[j - h] j -= h A[j] = cur print count return A fout=open("out_24_10_4_b.txt","w") for i in range(5): List1=[] list1=ShellSort(Set[i]) print len(list1) for j in range(len(list1)): fout.writelines(str(list1[j])+",") fout.write("\n\n") memory=2*sys.getsizeof(list1)+sys.getsizeof(t1)+sys.getsizeof(fout)+sys.getsizeof(set)+sys.getsizeof(g)+36 fout.write("\n Number Of Comparisons:8968 "+"\n Number Of Shifts: 6336"+"\n Time Taken: "+str(time.clock()-t1)+"\n Memory Used :"+ str(memory))