[Data Structure] Heap

Derek Fan
2 min readMay 20, 2019

--

  1. Max / Min Heap

2. Binary Heap

3. Peek -> O(1)

4. Search -> Worst: O(n) / Average: O(n/2) =~ O(n)

5. Insert / Extract -> Heapify -> Height of the Tree -> Worst Case: O(log(n))

6. Binary Heap can be implemented in Array, which can save us some space.

--

--