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 height of a binary tree is the maximum length of a path from the root to a leaf.
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,2,4,3), (1,3,2,4), (1,3,4,2), (1,4,2,3).
Their tree heights are 4, 3, 3, 3, 3, respectively.
Thus the total sum of heights is 16.
CROSSREFS
KEYWORD
nonn,more
AUTHOR
Manolopoulos Panagiotis, Oct 31 2025
EXTENSIONS
a(11)-a(15) from Sean A. Irvine, Nov 05 2025
STATUS
approved
