bubble sort by ksk

open Array
let n=read_int()let(!)=Printf.printf
let a=map read_int(make n())let
rec($)i?(x=a.(i+1))u s?(t=s+min(a.(i)/x)1)c=blit[|x;a.(i)|]0a i(t*2-s*2);iter!"%3d"a,!"compare =%3d   swap =%3d   data:"c t;!"
";[|i+1$u;0$u-1|].(i/u)t(c+1);;(0$n-2)0 1

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page