Bubble Sort

    0

    0

    Aakanksha Priya

    def bubblesort(arr):
    # Swap the elements to arrange in order
       for iter_num in range(len(arr)-1,0,-1):
          for idx in range(iter_num):
             if arr[idx]>arr[idx+1]:
                temp = arr[idx]
                arr[idx] = arr[idx+1]
                arr[idx+1] = temp
    arr= [45,89,56,78,90,12,10,2,34,1]
    bubblesort(arr)
    print(arr)
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.