Generator

Building a heap two ways, random input

Rendered here at the parameters it defaults to, with every essay that calls it — which is the same list as the blast radius of changing it.
Building a heap two ways, random inputComparisons against n on logarithmic axes. Bottom-up construction fits n at 1.86 comparisons per element. Repeated insertion is quoted as n log n, and on this input the flattest class for it is n at a spread of 1.09; at n = 65,536 it costs 1.21 times the bottom-up count, against a log₂ n of 16. The famous logarithmic factor is a worst case and this is not the worst case.10³10⁴10³10⁴10⁵ncomparisonsbottom-up (Floyd)repeated insertionn from 128 to 65,536, random input, seeded1.21× between the two at the right-hand edge

Building a heap two ways, random input

Comparisons against n on logarithmic axes. Bottom-up construction fits n at 1.86 comparisons per element. Repeated insertion is quoted as n log n, and on this input the flattest class for it is n at a spread of 1.09; at n = 65,536 it costs 1.21 times the bottom-up count, against a log₂ n of 16. The famous logarithmic factor is a worst case and this is not the worst case.

Drawn at 690 × 410, wide on the page. Everything above is what heap-build returns with no arguments; the caption is the generator's own, computed from the numbers in the drawing rather than written beside it.

1 essay calls heap-build. The drawing above is what it returns with no arguments at all; every call below passes it something, because a placement that passes nothing draws whichever member of the family the generator happens to default to rather than the one its essay argues about — which is what optcheck and figfill exist to catch.

Where it is called

Changing this generator changes every one of these figures.

The library, page 2 of 5 — where heap-build sits