Array inversion algorithms