def shellSort(unsorted_arr):
          gap = len(unsorted_arr) // 2
          while gap > 0:
              for i in range(gap, len(unsorted_arr)):
                  temp = unsorted_arr[i]
                  j = i
      # Sort the sub list for this gap
          while j >= gap and unsorted_arr[j - gap] > temp:
              unsorted_arr[j] = unsorted_arr[j - gap]
              j = j-gap
              unsorted_arr[j] = temp
      # Redu ce the gap for the next element
          gap = gap//2
      arr= [45,89,56,78,90,12,10,2,34,1]
      shellSort(arr)
      print(arr)
      
      Python language logo

      Shell Sort

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.