Nhảy tới nội dung

Heap

Before diving to heap, let's review types of binary tree, there are 3 of them:

Heaps are complete binary trees (which means ).

Heap types

There are 2 types of heap:

  • Min-heap: every parent < its children
  • Max-heap: every parent > its children

So, it means with min-heap, the smallest element is most parent node.

Building a heap