Inversion number Created 2026-10-20 Updated 2026-11-05
The inversion number of a permutation isFor
3142, the inverted pairs of values are , giving three. The inversion number ranges from zero for increasing order to for decreasing order; it is the minimum number of adjacent transpositions needed to sort the permutation. Its parity gives the sign of a permutation, . The same pair-counting formula defines the word inversion number when repeated symbols are allowed. Inversion of a word Created 2026-10-20 Updated 2026-11-05
For a word over a totally ordered alphabet, an inversion of a word is a pair of positions with . Equal symbols contribute no inversion of a word. In
baba, with , the pairs are , so the word inversion number is three. Counting these pairs records distance from sorted order even when letters repeat; replacing the letters by distinct ordered labels gives the inversion of a permutation case.