Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def shellSort(sample):
- print("sample=",sample)
- length = len(sample)
- gap = int(length/2)
- while(gap >= 1):
- i = gap
- while(i < length):
- value = sample[i]
- j = i
- while(j-gap >= 0 and value < sample[j - gap]):
- sample[j] = sample[j - gap]
- j -= gap
- sample[j] = value
- i+=1
- gap = int(gap/2)
- print("sorted sample=",sample)
- sample1 = [37,22,18,50,2,3,1,29,69,5]
- shellSort(sample1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement