Demo entry 6634761

shell

   

Submitted by anonymous on Aug 14, 2017 at 03:17
Language: Python. Code size: 229 Bytes.

def shell(arr):
 n=len(arr)
 h=1
 while h<n/3:
  h=3*h+1
 while h>=1:
  for i in range(h,n):
   j=i
   temp=arr[j]
   while j>=h and arr[j]<arr[j-h]:
    arr[j]=arr[j-h]
    arr[j-h]=temp
    j-=h
  h=h/3
 print arr

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).