9 Mayıs 2019 Perşembe

Binary Heap

Giriş
Açıklaması şöyle. Binary Heap'te sadece ata düğümün küçük değere sahip olduğu garanti edilir. Kardeş düşümler arasında büyüklük küçüklük karşılaştırılması yapılmaz
A binary heap is similar to a binary search in that there is a relationship between parent and child nodes. The difference is in what that relationship is. In a BST right children are larger than their parents, and left children are smaller.

But in a binary min-heap, parent nodes are smaller than both their children, all nodes are inserted in breadth-first order, and there is no relationship between sibling nodes. The relationships can also be easily represented in an array as a mathematical formula between indices.
Formül şöyle.
For a given index i
It's two children will be at (2i + 1) and (2i + 2)
So the children of the node at index 10 will be at 21 and 22

Hiç yorum yok:

Yorum Gönder