What’s the relationship between “a” heap and “the” heap?

Nothing much, to be honest. I would imagine that the word heap was simply taken with it’s everday (non-technical) usage and applied to these two concepts individually as reasonably good analogies.

In the first case (tree data structure meaning), the description heap is most appropiate because “greater” objects are placed higher up in the tree (where “greater” is determined by an arbitrary key function) – i.e. there’s a sort of piling of smaller objects on top of larger ones (or larger on top, depending how you think of it). This is just how I’d interpret it; whoever first applied the name heap to this data-structure thought it was an appropiate name in his mind, and it’s just stuck.

In the second case (chunks of RAM), the name of heap is maybe a bit more evident. “Heap” is just “a large collection of things in a highly arbitrary order” here, which would seem to apply just as well in common usage as it does to dynamically allocated chunks of memory.

In any case, I wouldn’t worry about the abstract metaphorical similarities you can draw between the two ideas. Treat them completely seperately and you won’t go wrong in any situation.

Edit: It seems the tree-based data structure may have taken its name from the heap of abstract algebra, as is reasonably common within computer science. However, I wouldn’t want to confirm or deny this…

Leave a Comment