Binary Heap
Binary Heap
Binary Heap (Binary Heap)
Introduction
A binary heap (binary heap) is a binary rooted tree for which the following conditions hold:
- Each vertex has no more than two children.
- The value of any vertex is not less than the values in its children (this is a max-heap).
Also, a heap is an almost complete binary tree:
- On the -th (starting from zero) layer there are vertices, except for the last.
- The last layer is filled from left to right.

Structure
It is convenient to store the heap in an array .