1. Heap - it can be used as a priority queue!

Untitled

n ≥ 2^h

→ h ≤ log(n)

**it's different from a binary search tree. We use bst to find an item or see if it has an item quickly, and we use a heap to get the item w the smallest key quickly

Untitled

2. Operation

Upheap

1 goes up from the bottom to the top

1 goes up from the bottom to the top

Downheap

7 goes down by swapping

7 goes down by swapping

Removal of min or max

Updating the last node for inserting