a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (in a max heap) or less than or equal to (in a min heap) the key of C. The node at the “top” of the heap (with no parents) is called the root node.
max heap: children are smaller or equal to parents
best way to implement a priority queue. In addition, peek (in this context often called find-max or find-min), which returns the highest-priority element but does not modify the queue, is very frequently implemented, and nearly always executes in O(1) time. Best implementation of a priority queue is usually a heap. So they are called heaps frequently
A heap is not a sorted structure and can be regarded as partially ordered.
A heap is a useful data structure when you need to remove or peek the object with the highest (or lowest) priority.
usually implemented as an array
you can write a method to turn an array into a heap by rearranging the items
Binary heaps are common
remove
insert
heapsort
just pop off the root and put it at the end of the array over and over until the heap is empty
populates top to bottom left to right
when removing the root element, replace it with the last element at the bottom and move it to thr right spot
if storing in an array you can get left child i*2+1, right child i*2+2