OFFSET
1,2
COMMENTS
Sorting methods have been constructed such that the lower bound of f(n) is achieved for n=1, 2, 3, 4, 5, 6, 9 and 10. Y. Césari was the first to show that f(7) is not obtainable. He also constructed optimal solutions for n=9 and 10. L. Kollár showed that the minimum number of comparisons needed for n=7 is 62416. - Dmitry Kamenetsky, Jun 11 2015
REFERENCES
Y. Césari, Questionnaire codage et tris, PhD Thesis, University of Paris, 1968.
D. E. Knuth, TAOCP, Vol. 3, Section 5.3.1.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..450
L. Kollár, Optimal sorting of seven element sets, Proceedings of the 12th symposium on Mathematical foundations of computer science 1986, 449-457.
FORMULA
Knuth gives an explicit formula.
a(n) = (q(n)+1)*n! - 2^q(n) with q(n) = A003070(n).
MAPLE
q:= n-> ceil(log[2](n!)):
a:= n-> (q(n)+1)*n! - 2^q(n):
seq(a(n), n=1..30); # Alois P. Heinz, Jun 11 2015
MATHEMATICA
q[n_] := Log[2, n!] // Ceiling; a[n_] := (q[n]+1)*n! - 2^q[n]; Array[a, 20] (* Jean-François Alcover, Feb 13 2016 *)
PROG
(PARI) a(n) = { my(N=n!, q = ceil(log(N)/log(2))); return ((q+1)*N - 2^q); } \\ Michel Marcus, Apr 21 2013
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Oct 06 2006
STATUS
approved