![]() |
VOOZH | about |
:
A Binary Heap is a Binary Tree with following properties.
Example of Min-Heap:
Binomial Heap:
A Binomial Heap is a collection of Binomial Tree where each Binomial Tree follows the Min-Heap property and there can be at most one Binomial Tree of any degree.
Example of Binomial Heap:
π ImageThe key difference between a Binary Heap and a Binomial Heap is how the heaps are structured. In a Binary Heap, the heap is a single tree, which is a complete binary tree. In a Binomial Heap, the heap is a collection of smaller trees (that is, a forest of trees), each of which is a binomial tree. A complete binary tree can be built to hold any number of elements, but the number of elements in a binomial tree of some order N is always 2^N. Consequently, one complete binary tree is needed to back a Binary Heap, but we may need multiple binomial trees to back a Binomial Heap.
:
Like Binomial Heap, Fibonacci Heap is a collection of trees with Min-Heap or Max-Heap property. In Fibonacci Heap, trees can have any shape even all trees can be single nodes (This is unlike Binomial Heap where every tree has to be a Binomial Tree). Fibonacci Heap maintains a pointer to a minimum value (which is the root of a tree). All tree roots are connected using a circular doubly linked list, so all of them can be accessed using a single βminβ pointer.
Example of Fibonacci Heap:
π ImageThe difference in time complexities of various operations associated with Binary heap, Binomial heap, and Fibonacci heaps are mentioned in the following table.
| Operation | Binary Heap | Binomial Heap | Fibonacci Heap |
|---|---|---|---|
| insert | O(log N) | O(log N) | O(1) |
| find-min | O(1) | O(log N) | O(1) |
| delete | O(log N) | O(log N) | O(log N) |
| decrease-key | O(log N) | O(log N) | O(1) |
| union | O(N) | O(log N) | O(1) |