login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A288964 Number of key comparisons to sort all n! permutations of n elements by quicksort. 8
0, 0, 2, 16, 116, 888, 7416, 67968, 682272, 7467840, 88678080, 1136712960, 15655438080, 230672171520, 3621985113600, 60392753971200, 1065907048550400, 19855856150323200, 389354639411404800, 8017578241634304000, 172991656889856000000, 3903132531903897600000 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

LINKS

Daniel Krenn, Table of n, a(n) for n = 0..100

Index entries for sequences related to sorting

FORMULA

a(n) / n! = 2*(n+1)*H(n) - 4*n.

c(n) = a(n) / n! satisfies c(n) = (n-1) + 2/n * Sum_{i < n} c(i).

a(n) = 2*A002538(n-1), n >= 2. - Omar E. Pol, Jun 20 2017

E.g.f.: -2*log(1-x)/(1-x)^2 - 2*x/(1-x)^2. - Daniel Krenn, Jun 20 2017

a(n) = ((2*n^2-3*n-1)*a(n-1) -(n-1)^2*n*a(n-2))/(n-2) for n >= 3, a(n) = n*(n-1) for n<3. - Alois P. Heinz, Jun 21 2017

MAPLE

a:= proc(n) option remember; `if`(n<3, n*(n-1),

      ((2*n^2-3*n-1)*a(n-1)-(n-1)^2*n*a(n-2))/(n-2))

    end:

seq(a(n), n=0..25);  # Alois P. Heinz, Jun 21 2017

PROG

(SageMath) [n.factorial() * (2*(n+1)*sum(1/k for k in srange(1, n+1)) - 4*n) for n in srange(21)]

(SageMath) # alternative using the recurrence relation

@cached_function

def c(n):

    if n <= 1:

        return 0

    return (n - 1) + 2/n*sum(c(i) for i in srange(n))

[n.factorial() * c(n) for n in srange(21)]

CROSSREFS

Cf. A096620, A115107, A117627, A117628, A159324, A288965.

Sequence in context: A208364 A207711 A162723 * A193289 A159324 A088755

Adjacent sequences:  A288961 A288962 A288963 * A288965 A288966 A288967

KEYWORD

nonn

AUTHOR

Daniel Krenn, Jun 20 2017

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified January 26 20:42 EST 2020. Contains 331288 sequences. (Running on oeis4.)