OFFSET
1,9
COMMENTS
A permutation of [1..n] is heapable if it can be inserted, one element at a time, into a binary min-heap without violating the heap property.
An inversion in a permutation p of length n is a pair of indices (i,j) with i<j such that p(i)>p(j).
The total number of inversions is the number of such pairs.
LINKS
Sean A. Irvine, Table of n, a(n) for n = 1..575 (rows 1..15 flattened, rows 1..10 from Manolopoulos Panagiotis)
Benjamin Chen, Michael Cho, Mario Tutuncu-Macias, and Tony Tzolov, Efficient methods of calculating the number of heapable permutations, Discrete Applied Mathematics Volume 331, 31 May 2023, Pages 126-137.
Manolopoulos Panagiotis, Python program.
EXAMPLE
Triangle begins:
1
1, 0
1, 1, 0, 0
1, 2, 2, 0, 0, 0, 0
1, 3, 5, 5, 3, 0, 0, 0, 0, 0, 0
1, 4, 9, 14, 17, 15, 9, 2, 0, 0, 0, 0, 0, 0, 0, 0
1, 5, 14, 28, 45, 60, 67, 61, 45, 24, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
1, 6, 20, 48, 93, 153, 220, 279, 314, 312, 271, 202, 123, 58, 22, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
Manolopoulos Panagiotis, Oct 13 2025
STATUS
approved
