In computer science and discrete mathematics, an inversion in a sequence is a pair of elements that are out of their natural order.
Let be a permutation. There is an inversion of between and if and . The inversion is indicated by an ordered pair containing either the places or the elements