• + 0 comments
    count=0
        for i in range(n):
            
            for j in range(n-1):
                if a[j]>a[j+1]:
                    a[j],a[j+1]=a[j+1],a[j]
                    count+=1
            if count==0:
                break
        print('Array is sorted in',count,'swaps.')
        print('First Element:', a[0])
        print('Last Element:', a[-1])