bubble sort in python

Bubble Sort

for variable in sequence:

   Statement block

Range function prototype is (start, stop, [step]) start, end, step

Must be an integer parameter type to use two parameters to create a [start, end] list of consecutive integers in the interval,

If the third argument, a tolerance within the interval arithmetic step is to create a number of columns.

= A [. 3,. 6,. 4, 2,. 11, 10,. 5 ] 


DEF bubble_sort (A):
     # calculating list element number, count from zero, so filled -1 
    COUNT = len (A) -1 for I in Range (COUNT, 0, -1 ):
         for J in Range (I):
             IF A [J]> A [+ J. 1 ]: 
                A [J], A [J + 1'd] = A [+ J. 1 ], A [J] return A Print (buddle_sort (A))

    

    


 

 

Guess you like

Origin www.cnblogs.com/yi-xixi/p/10973315.html