Home : Bits and Bytes : Heap Definition


A heap is a data structure made up of "nodes" that contain values. A typical heap has a root node at the top, which may have two or more child nodes directly below it. Each node can have two or more child nodes, which means the heap becomes wider with each child node. When displayed visually, a heap looks like an upside down tree and the general shape is a heap.

While each node in a heap may have two or more child nodes (also called "children"), most heaps limit each node to two children. These types of heaps are also called binary heaps and may be used for storing sorted data. For example, a "binary max heap" stores the highest value in the root node. The second and third highest values are stored in the child nodes of the root node. Throughout the tree, each node has a greater value than either of its child nodes. A "binary min heap" is the opposite, where the root node stores the lowest value and each node has a lower value than its children.

In computer science, heaps are often drawn as simple diagrams. However, actually storing data in a heap is more complex. In order to create a heap, programmers must write individual algorithms for inserting and deleting data. The values inserted into a heap are typically stored in an array, which can be referenced by a program. Since the data in a heap is already sorted, it provides an efficient means of searching for specific values.

NOTE: "The heap" is also a programming term that may be used to describe dynamically allocated memory. This block of memory can be accessed by active applications. Since memory in the heap is allocated dynamically, it may grow or shrink depending on how much memory is being used.

Updated: August 2, 2012

Cite this definition:


TechTerms - The Tech Terms Computer Dictionary

This page contains a technical definition of Heap. It explains in computing terminology what Heap means and is one of many computing terms in the TechTerms dictionary.

All definitions on the TechTerms website are written to be technically accurate but also easy to understand. If you find this Heap definition to be helpful, you can reference it using the citation links above. If you think a term should be updated or added to the TechTerms dictionary, please email TechTerms!

Subscribe to the TechTerms Newsletter to get featured terms and quizzes right in your inbox. You can choose to receive either a daily or weekly email.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe at any time.
Questions? Please contact us.