3 ms·
One more thing: a heap can be easily packed contiguously in memory, while the tree nodes are typically dynamically allocated. This helps with allocation pressu
by branko_d 5y ago
One more thing: a heap can be easily packed contiguously in memory, while the tree nodes are typically dynamically allocated.
This helps with allocation pressure, which is often the "hidden" cost people don't pay enough attention to, especially in garbage-collected languages where the allocation might appear to be almost "free" (often a simple bump allocator), but the deallocation price is paid at later indeterminate time (when the GC runs).