Trusted answers to developer questions

# What is a Heap?

Educative Answers Team

Free System Design Interview Course

Get Educative's definitive System Design Interview Handbook for free.

Heaps are advanced data structures that are useful for specific use-cases such as sorting and implementing priority queues.

## Characteristics

Heaps can be thought of as regular binary trees with two special characteristics.

• Heaps must be Complete Binary Trees.
• The nodes must be ordered according to the Heap order property. Two heap order properties are as follows:

#### Max Heap Property:

All the parent node keys must be greater than or equal to their child node keys in max-heaps. So the root node will always contain the largest element in the Heap. If Node A has a child node B, then,

$key(A) >=key(B)$

#### Min Heap Property:

In Min-Heaps, all the parent node keys are less than or equal to their child node keys. So the root node, in this case, will always contain the smallest element present in the Heap. If Node A has a child node B, then:

$key(A) <=key(B)$

RELATED TAGS

data structures
heap
Copyright ©2023 Educative, Inc. All rights reserved
Trusted Answers to Developer Questions

Related Tags

data structures
heap
Keep Exploring
Related Courses

Learn in-demand tech skills in half the time

Copyright ©2023 Educative, Inc. All rights reserved.