⬅ Previous Topic
Bucket SortNext Topic ⮕
Find Maximum and Minimum in Array using Loop⬅ Previous Topic
Bucket SortNext Topic ⮕
Find Maximum and Minimum in Array using Loopdef shell_sort(arr):
n = len(arr)
gap = n // 2
while gap > 0:
for i in range(gap, n):
temp = arr[i]
j = i
while j >= gap and arr[j - gap] > temp:
arr[j] = arr[j - gap]
j -= gap
arr[j] = temp
gap //= 2
return arr
if __name__ == '__main__':
arr = [6, 3, 8, 2, 7, 4]
shell_sort(arr)
print("Sorted array is:", arr)
⬅ Previous Topic
Bucket SortNext Topic ⮕
Find Maximum and Minimum in Array using LoopYou can support this website with a contribution of your choice.
When making a contribution, mention your name, and programguru.org in the message. Your name shall be displayed in the sponsors list.