Heap: A data “structure” made up of a series of branching nodes

When organized properly, a heap should look remarkably like an upside- down tree, or a heap of data. It gets this look from the way the nodes are organized in its structure: each node branches down into (usually) two nodes.

This is where the term “child nodes,” or “children” comes from. As each now branches out into its children, it spreads down and out indefinitely, with the original node at the very top being the “root” node.

This form of heap is often called binary heap because of its two pronged nodes.  Heaps are mainly used as a way to organize data in an easily accessible structure, though it can be applied in programming as a system of dynamic memory.

And while the structure sounds simple enough- the diagram, after all, is easy to draw and visualize- it is actually quite difficult and complex to put together.

There are two possible binary heaps: binary min and binary max. As the names seem to suggest, a binary min starts in the root at its lowest data point, and each subsequent data point has more value than those before it.

A binary max is the opposite, starting at its highest data point and getting progressively lower as it builds. Think of it like this: in a binary min, each child has a higher value than its parent node; and in a binary max each child has a lower value than its parent.

In order to store these values, programmers must write individual algorithms for placing and retrieving the data. To make it efficient, data is stored in an array (groups of the same data type) so it can be quickly accessed by a program.

Read more