OFFSET
1,2
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.
The first run (or initial increasing segment) of a permutation is the maximal prefix that is strictly increasing: p1 < p2 < ... < pk.
The length of the first run is k.
LINKS
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
For n=4, the heapable permutations are: (1,2,3,4), (1,3,2,4), (1,2,4,3), (1,4,2,3), (1,3,4,2).
Lengths of first runs:
(1,2,3,4): run 1,2,3,4 length 4.
(1,3,2,4): run 1,3 length 2.
(1,2,4,3): run 1,2,4 length 3.
(1,4,2,3): run 1,4 length 2.
(1,3,4,2): run 1,3,4 length 3.
So among the 5 heapable permutations of length 4:
1 permutation has first run of length 4,
2 permutations have first run of length 3,
2 permutations have first run of length 2,
for a total of 14.
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Manolopoulos Panagiotis, Oct 06 2025
EXTENSIONS
a(12)-a(15) from Sean A. Irvine, Oct 12 2025
a(16) from Sean A. Irvine, Oct 13 2025
STATUS
approved
