0% found this document useful (0 votes)
21 views1 page

What Is A Heap

A heap is a special binary tree where each parent node's value is greater than or equal to its child nodes, and it is either fully filled or nearly complete. There are two types of heaps: max-heaps, where the parent is larger than its children, and min-heaps, where the parent is smaller. Heaps are often implemented using arrays for efficient processing and memory usage.

Uploaded by

Irfan Ul Haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

What Is A Heap

A heap is a special binary tree where each parent node's value is greater than or equal to its child nodes, and it is either fully filled or nearly complete. There are two types of heaps: max-heaps, where the parent is larger than its children, and min-heaps, where the parent is smaller. Heaps are often implemented using arrays for efficient processing and memory usage.

Uploaded by

Irfan Ul Haq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

What is a Heap?

A heap is a special kind of binary tree with specific properties:

1. Parent-Child Relationship: Each parent node’s value is greater than (or equal to) the
values of its child nodes.
2. Complete Tree: It is either fully filled or nearly complete, meaning the last level is filled
from left to right.

 Max-Heap: The parent node is larger than its children.


 Min-Heap: The parent node is smaller than its children.
Unless stated otherwise, a "heap" usually refers to a max-heap.

Key Features:

1. Root Node: In a max-heap, the largest value is at the root. In a min-heap, the smallest
value is at the root.
2. Subtrees: The left and right branches of any node follow the same rules, but the child
nodes' order (left or right) does not matter.
3. Array Implementation: Instead of linked nodes, heaps are often stored in arrays.
o The position of a node's children can be calculated efficiently.
o This makes processing fast and memory-efficient.

You might also like