num of inversion algorithm