# Data structure - 🆎 Heap & 📈 Priority Queue

Heap is actually an array physically, but logically it’s a tree-based data structure.
We often use MinPriorityQueue and MaxPriorityQueue in JavaScript.

MinHeap implementation

Min/Max Priority Queue

Note:
PQ is quite simimlar to normal binary heaps, but the element can be objects but no just numbers. And sometimes we need more complex comparator to diff priorities. Hence a comparator is necessary in constructor.

Time complexity