Content deleted Content added
removed improper bolding as per MOS:BOLD |
Adding short description: "Scheme for numbering permutations" |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1:
{{Short description|Scheme for numbering permutations}}
In [[mathematics]] and in particular in [[combinatorics]], the '''Lehmer code''' is a particular way to [[encoding|encode]] each possible [[permutation]] of a sequence of ''n'' numbers. It is an instance of a scheme for [[Permutation#Numbering permutations|numbering permutations]] and is an example of an [[inversion (discrete mathematics)|inversion]] table.
The Lehmer code is named in reference to [[
==The code==
The Lehmer code makes use of the fact that there are
:<math>n!=n\times(n-1)\times\cdots\times2\times1</math>
permutations of a sequence of ''n'' numbers. If a permutation ''σ'' is specified by the sequence (''σ''<sub>1</sub>, ..., ''σ
:<math>L(\sigma)=(L(\sigma)_1,\ldots,L(\sigma)_n)\quad\text{where}\quad L(\sigma)_i=\#\{ j>i : \sigma_j<\sigma_i \},</math>
in other words the term ''L''(''σ'')<sub>''i''</sub> counts the number of terms in (''σ''<sub>1</sub>, ..., ''σ
A pair of indices (''i'',''j'') with {{math|''i'' < ''j''}} and {{math|''σ
at position ''i'' similarly signifies a right-to-left maximum, and that the Lehmer code of ''σ'' coincides with the [[factorial number system]] representation of its position in the list of permutations of ''n'' in lexicographical order (numbering the positions starting from 0).
Variations of this encoding can be obtained by counting inversions (''i'',''j'') for fixed ''j'' rather than fixed ''i'', by counting inversions with a fixed smaller ''value'' {{math|''σ
==Encoding and decoding==
The usual way to prove that there are ''n''! different permutations of ''n'' objects is to observe that the first object can be chosen in {{math|''n''}} different ways, the next object in {{math|''n'' − 1}} different ways (because choosing the same number as the first is forbidden), the next in {{math|''n'' − 2}} different ways (because there are now 2 forbidden values), and so forth. Translating this freedom of choice at each step into a number, one obtains an encoding algorithm, one that finds the Lehmer code of a given permutation. One need not suppose the objects permuted to be numbers, but one needs a [[total ordering]] of the set of objects. Since the code numbers are to start from 0, the appropriate number to encode each object ''σ
This number to encode each object can be found by direct counting, in several ways (directly counting inversions, or correcting the total number of objects smaller than a given one, which is its sequence number starting from 0 in the set, by those that are unavailable at its position). Another method which is in-place, but not really more efficient, is to start with the permutation of {0, 1, ... {{math|''n'' − 1}}} obtained by representing each object by its mentioned sequence number, and then for each entry ''x'', in order from left to right, correct the items to its right by subtracting 1 from all entries (still) greater than ''x'' (to reflect the fact that the object corresponding to ''x'' is no longer available). Concretely a Lehmer code for the permutation B,F,A,G,D,E,C of letters, ordered alphabetically, would first give the list of sequence numbers 1,5,0,6,3,4,2, which is successively transformed
Line 38 ⟶ 39:
=== Independence of relative ranks ===
The Lehmer code defines a bijection from the [[symmetric group]] ''S
=== Number of right-to-left minima and maxima ===
Line 63 ⟶ 64:
This is an optimal stop problem, a classic in decision theory, statistics and applied probabilities, where a random permutation is gradually revealed through the first elements of its Lehmer code, and where the goal is to stop exactly at the element k such as σ(k)=n, whereas the only available information (the k first values of the Lehmer code) is not sufficient to compute σ(k).
In less mathematical words
The interviewer thus knows the rank of the k<sup>th</sup> applicant, therefore, at the moment of making his k<sup>th</sup> decision, the interviewer knows only the k first elements of the Lehmer code whereas he would need to know all of them to make a well informed decision.
Line 71 ⟶ 72:
==Similar concepts==
▲Two similar vectors are in use. One of them is often called inversion vector, e.g. by [[Wolfram Alpha]].
See also {{Section link|Inversion_(discrete_mathematics)|Inversion related vectors}}.
Line 79:
==References==
{{Reflist|refs=
<ref name="lehmer">
{{Citation
| last=Lehmer
| first=D.H.
| title=Combinatorial Analysis
| chapter=Teaching combinatorial tricks to a computer | series=Proceedings of Symposia in Applied Mathematics
| author-link=D. H. Lehmer
| volume=10
| year=1960
| pages=179–193
| doi=10.1090/psapm/010/0113289
| isbn=978-0-8218-1310-2
| mr=0113289
}}
</ref>
Line 96 ⟶ 101:
| last=Laisant
| first=Charles-Ange
| author-link= Charles-Ange Laisant
| title=Sur la numération factorielle, application aux permutations
| trans-title=On factorial numbering, application to permutations
| journal=Bulletin de la Société Mathématique de France
| volume=16
| issue=<!--1 of 1-->
| year=1888
| pages=176–183
| url=http://www.numdam.org/item?id=BSMF_1888__16__176_0
| doi=10.24033/bsmf.378
}}
</ref>
Line 109 ⟶ 117:
| last=Ferguson
| first=Thomas S.|authorlink= Thomas S. Ferguson
| title=Who solved the secretary problem
| journal=Statistical Science
| volume=4
| issue=3
|
| pages=282–289
| jstor=2245639
| doi=10.1214/ss/1177012493
| doi-access=free
| url=https://www2.math.upenn.edu/~ted/210F10/References/Secretary.pdf
}}
</ref>
Line 141 ⟶ 150:
*{{ Citation
| last1=Knuth
| first1=
| author-link=Donald Knuth
| title=The
| volume=3
| publisher=Addison-Wesley
|