cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A079884 Number of comparisons required to create all permutations of n distinct elements using the "streamlined" version of Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2.

This page as a plain text file.
%I A079884 #13 Jun 05 2024 10:02:15
%S A079884 11,54,285,1731,12145,97196,874809,8748145,96229661,1154756010,
%T A079884 15011828221,210165595199,3152483928105,50439742849816,
%U A079884 857475628447025,15434561312046621,293256664928885989,5865133298577719990,123167799270132120021,2709691583942906640715,62322906430686852736721
%N A079884 Number of comparisons required to create all permutations of n distinct elements using the "streamlined" version of Algorithm L (lexicographic permutation generation) from Knuth's The Art of Computer Programming, Vol. 4, chapter 7.2.1.2.
%C A079884 The method generates all permutations in lexicographic order. It is described in the answer to Exercise 1, Section 7.2.1.2 of Knuth's The Art of Computer Programming Vol. 4. The description is based on the Algol procedure NEXTPERM by J.P.N.Phillips. The operation counts were determined with a FORTRAN subroutine LPG. To create all permutations of n distinct elements the number of comparisons between the array elements approaches 2.410756*n! for large n (e.g. n>8).
%D A079884 D. E. Knuth: The Art of Computer Programming, Volume 4, Combinatorial Algorithms, Volume 4A, Enumeration and Backtracking. Pre-fascicle 2B, A draft of section 7.2.1.2: Generating all permutations.
%D A079884 J. P. N. Phillips: "Algorithm 28, PERMUTATIONS OF THE ELEMENTS OF A VECTOR IN LEXICOGRAPHIC ORDER" The Computer Journal, Volume 10, Issue 3: November 1967. (Algorithms supplement), page 311. See link.
%H A079884 Hugo Pfoertner, <a href="https://www.randomwalk.de/sequences/lpgcount.txt">FORTRAN program for lexicographic permutation generation</a>.
%H A079884 J. P. N. Phillips, <a href="https://doi.org/10.1093/comjnl/10.3.306">Algorithm 28 from Algorithms supplement</a>.
%F A079884 a(3) = 11; a(n) = n*a(n-1) + n*(n+1)/2.
%F A079884 a(n) = 2*n! - 1 + A079750(n) + A079753(n).
%F A079884 For n>=3, a(n)=floor(c*n!-(n-3)/2) where c = lim_{n->oo} a(n)/n! = 2.4107560760219... - _Benoit Cloitre_; c=3*e/2-5/3 - Guido Dhondt (dhondt(AT)t-online.de), Jan 20 2003
%e A079884 The "streamlined" permutation algorithm L' needs fewer comparisons a(n) than the original Algorithm L, for which the number of required comparisons between the elements to be permuted is given by A038156(n) for step L2 and A038155(n) for step L3. A038156(3)+A038155(3)=9+6=15 > a(3)=11 A038156(4)+A038155(4)=40+30=70 > a(4)=54 A038156(10)+A038155(10)=6235300+4932045=11167345 > a(10)=8748145.
%o A079884 (Fortran) Program available at Pfoertner link
%o A079884 (PARI) a079884(nmax) = {my(a=vector(nmax)); a[3]=11; for(k=4, nmax, a[k]=k*a[k-1]+k*(k+1)/2); a[3..nmax]} \\ _Hugo Pfoertner_, Jun 05 2024
%Y A079884 Partial counts given in A079750, A079753.
%Y A079884 Number of index tests: A079885.
%Y A079884 Cf. A000217, A000142, A038155, A038156.
%K A079884 easy,nonn
%O A079884 3,1
%A A079884 _Hugo Pfoertner_, Jan 12 2003