HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
and
discrete mathematics Discrete mathematics is the study of mathematical structures that can be considered "discrete" (in a way analogous to discrete variables, having a bijection with the set of natural numbers) rather than "continuous" (analogously to continuous f ...
, an inversion in a sequence is a pair of elements that are out of their natural
order Order, ORDER or Orders may refer to: * A socio-political or established or existing order, e.g. World order, Ancien Regime, Pax Britannica * Categorization, the process in which ideas and objects are recognized, differentiated, and understood ...
.


Definitions


Inversion

Let \pi be a
permutation In mathematics, a permutation of a set can mean one of two different things: * an arrangement of its members in a sequence or linear order, or * the act or process of changing the linear order of an ordered set. An example of the first mean ...
. There is an inversion of \pi between i and j if i < j and \pi(i) > \pi(j). The inversion is indicated by an ordered pair containing either the places (i, j) or the elements \bigl(\pi(i), \pi(j)\bigr). The inversion set is the set of all inversions. A permutation's inversion set using place-based notation is the same as the inverse permutation's inversion set using element-based notation with the two components of each ordered pair exchanged. Likewise, a permutation's inversion set using element-based notation is the same as the inverse permutation's inversion set using place-based notation with the two components of each ordered pair exchanged. Inversions are usually defined for permutations, but may also be defined for sequences:
Let S be a
sequence In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is cal ...
(or
multiset In mathematics, a multiset (or bag, or mset) is a modification of the concept of a set that, unlike a set, allows for multiple instances for each of its elements. The number of instances given for each element is called the ''multiplicity'' of ...
permutation). If i < j and S(i) > S(j), either the pair of places (i, j) or the pair of elements \bigl(S(i), S(j)\bigr) is called an inversion of S. For sequences, inversions according to the element-based definition are not unique, because different pairs of places may have the same pair of values.


Inversion number

The inversion number \mathtt(X) of a sequence X=\langle x_1,\dots,x_n\rangle, is the
cardinality The thumb is the first digit of the hand, next to the index finger. When a person is standing in the medical anatomical position (where the palm is facing to the front), the thumb is the outermost digit. The Medical Latin English noun for thum ...
of the inversion set. It is a common measure of sortedness (sometimes called presortedness) of a permutation or sequence. The inversion number is between 0 and \frac2 inclusive. A permutation and its inverse have the same inversion number. For example \mathtt(\langle1,2,\dots, n\rangle)=0 since the sequence is ordered. Also, when n = 2m is even, \mathtt(\langle m+1,m+2,\dots,2m,1,2,\dots, m\rangle)=m^2 (because each pair (1\le i\le m < j\le 2m) is an inversion). This last example shows that a set that is intuitively "nearly sorted" can still have a quadratic number of inversions. The inversion number is the number of crossings in the arrow diagram of the permutation, the permutation's Kendall tau distance from the identity permutation, and the sum of each of the inversion related vectors defined below. Other measures of sortedness include the minimum number of elements that can be deleted from the sequence to yield a fully sorted sequence, the number and lengths of sorted "runs" within the sequence, the Spearman footrule (sum of distances of each element from its sorted position), and the smallest number of exchanges needed to sort the sequence. Standard
comparison sort A comparison sort is a type of sorting algorithm that only reads the list elements through a single abstract comparison operation (often a "less than or equal to" operator or a three-way comparison) that determines which of two elements should oc ...
ing algorithms can be adapted to compute the inversion number in time .


Inversion related vectors

Three similar vectors are in use that condense the inversions of a permutation into a vector that uniquely determines it. They are often called ''inversion vector'' or ''
Lehmer code In mathematics and in particular in combinatorics, the Lehmer code is a particular way to encode each possible permutation of a sequence of ''n'' numbers. It is an instance of a scheme for numbering permutations and is an example of an inversion ...
''. (A list of sources is found
here Here may refer to: Music * ''Here'' (Adrian Belew album), 1994 * ''Here'' (Alicia Keys album), 2016 * ''Here'' (Cal Tjader album), 1979 * ''Here'' (Edward Sharpe album), 2012 * ''Here'' (Idina Menzel album), 2004 * ''Here'' (Merzbow album), ...
.) This article uses the term ''inversion vector'' (v) like Wolfram. The remaining two vectors are sometimes called ''left'' and ''right inversion vector'', but to avoid confusion with the inversion vector this article calls them ''left inversion count'' (l) and ''right inversion count'' (r). Interpreted as a factorial number the left inversion count gives the permutations reverse colexicographic,Reverse colex order of finitary permutations and the right inversion count gives the lexicographic index. Inversion vector v:
With the ''element-based'' definition v(i) is the number of inversions whose ''smaller'' (right) component is i. :v(i) is the number of elements in \pi greater than i before i. :v(i) ~~=~~ \# \ Left inversion count l:
With the ''place-based'' definition l(i) is the number of inversions whose ''bigger'' (right) component is i. :l(i) is the number of elements in \pi greater than \pi(i) before \pi(i). :l(i) ~~=~~ \# \left\ Right inversion count r, often called ''
Lehmer code In mathematics and in particular in combinatorics, the Lehmer code is a particular way to encode each possible permutation of a sequence of ''n'' numbers. It is an instance of a scheme for numbering permutations and is an example of an inversion ...
'':
With the ''place-based'' definition r(i) is the number of inversions whose ''smaller'' (left) component is i. :r(i) is the number of elements in \pi smaller than \pi(i) after \pi(i). :r(i) ~~=~~ \# \ Both v and r can be found with the help of a Rothe diagram, which is a
permutation matrix In mathematics, particularly in matrix theory, a permutation matrix is a square binary matrix that has exactly one entry of 1 in each row and each column with all other entries 0. An permutation matrix can represent a permutation of elements. ...
with the 1s represented by dots, and an inversion (often represented by a cross) in every position that has a dot to the right and below it. r(i) is the sum of inversions in row i of the Rothe diagram, while v(i) is the sum of inversions in column i. The permutation matrix of the inverse is the transpose, therefore v of a permutation is r of its inverse, and vice versa.


Example: All permutations of four elements

The following sortable table shows the 24 permutations of four elements (in the \pi column) with their place-based inversion sets (in the p-b column), inversion related vectors (in the v, l, and r columns), and inversion numbers (in the # column). (The columns with smaller print and no heading are reflections of the columns next to them, and can be used to sort them in
colexicographic order In mathematics, the lexicographic or lexicographical order (also known as lexical order, or dictionary order) is a generalization of the alphabetical order of the dictionaries to sequences of ordered symbols or, more generally, of elements of a ...
.) It can be seen that v and l always have the same digits, and that l and r are both related to the place-based inversion set. The nontrivial elements of l are the sums of the descending diagonals of the shown triangle, and those of r are the sums of the ascending diagonals. (Pairs in descending diagonals have the right components 2, 3, 4 in common, while pairs in ascending diagonals have the left components 1, 2, 3 in common.) The default order of the table is reverse colex order by \pi, which is the same as colex order by l. Lex order by \pi is the same as lex order by r.


Weak order of permutations

The set of permutations on ''n'' items can be given the structure of a
partial order In mathematics, especially order theory, a partial order on a set is an arrangement such that, for certain pairs of elements, one precedes the other. The word ''partial'' is used to indicate that not every pair of elements needs to be comparable ...
, called the weak order of permutations, which forms a lattice. The
Hasse diagram In order theory, a Hasse diagram (; ) is a type of mathematical diagram used to represent a finite partially ordered set, in the form of a drawing of its transitive reduction. Concretely, for a partially ordered set (S,\le) one represents each ...
of the inversion sets ordered by the
subset In mathematics, a Set (mathematics), set ''A'' is a subset of a set ''B'' if all Element (mathematics), elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they a ...
relation forms the
skeleton A skeleton is the structural frame that supports the body of most animals. There are several types of skeletons, including the exoskeleton, which is a rigid outer shell that holds up an organism's shape; the endoskeleton, a rigid internal fra ...
of a
permutohedron In mathematics, the permutohedron (also spelled permutahedron) of order is an -dimensional polytope embedded in an -dimensional space. Its vertex (geometry), vertex coordinates (labels) are the permutations of the first natural numbers. The edg ...
. If a permutation is assigned to each inversion set using the place-based definition, the resulting order of permutations is that of the permutohedron, where an edge corresponds to the swapping of two elements with consecutive values. This is the weak order of permutations. The identity is its minimum, and the permutation formed by reversing the identity is its maximum. If a permutation were assigned to each inversion set using the element-based definition, the resulting order of permutations would be that of a
Cayley graph In mathematics, a Cayley graph, also known as a Cayley color graph, Cayley diagram, group diagram, or color group, is a Graph (discrete mathematics), graph that encodes the abstract structure of a group (mathematics), group. Its definition is sug ...
, where an edge corresponds to the swapping of two elements on consecutive places. This Cayley graph of the symmetric group is similar to its permutohedron, but with each permutation replaced by its inverse.


See also

*
Factorial number system In combinatorics, the factorial number system (also known as factoradic), is a mixed radix numeral system adapted to numbering permutations. It is also called factorial base, although factorials do not function as base, but as place value of ...
* Permutation graph * Transpositions, simple transpositions, inversions and sorting * Damerau–Levenshtein distance *
Parity of a permutation In mathematics, when ''X'' is a finite set with at least two elements, the permutations of ''X'' (i.e. the bijective functions from ''X'' to ''X'') fall into two classes of equal size: the even permutations and the odd permutations. If any total ...
Sequences in the
OEIS The On-Line Encyclopedia of Integer Sequences (OEIS) is an online database of integer sequences. It was created and maintained by Neil Sloane while researching at AT&T Labs. He transferred the intellectual property and hosting of the OEIS to th ...
:
Sequences related to factorial base representation
* Factorial numbers: and * Inversion numbers: * Inversion sets of finite permutations interpreted as binary numbers:   (related permutation: ) * Finite permutations that have only 0s and 1s in their inversion vectors:   (their inversion sets: ) * Number of permutations of ''n'' elements with ''k'' inversions; Mahonian numbers:   (their row maxima; Kendall-Mann numbers: ) * Number of connected labeled graphs with ''n'' edges and ''n'' nodes:


References


Source bibliography

* * * * * * * * * * *


Further reading

*


Presortedness measures

* * * {{refend Permutations Order theory String metrics Sorting algorithms Combinatorics Discrete mathematics