Is it possible for a Fibonacci heap to contain a tree that isn't a binomial tree? If so, how would this happen? Can you give an example?
1 Answers
Yes, this can happen. Intuitively, the reason is that in a Fibonacci heap, the decrease-key operation can work by cutting a subtree from a larger tree, resulting in two trees that are (potentially) not binomial trees. This differs from the binomial heap, where decrease-key works by doing a bubble-up operation from the node whose key was decreased all the way up to the root.
To see a concrete example, let's insert five elements into a Fibonacci heap, say, 1, 3, 5, 7, and 9. This gives the heap
1 - 3 - 5 - 7 - 9
Now, let's do a dequeue-min, which extracts 1. We now try to compact all of the remaining elements together, which merges the trees as follows:
3
/|
5 7
|
9
Now, suppose that we do a decrease-key operation on to decrease the key of 9 to 6. To do this, we cut 9 from its parent and merge it into the list of trees at the top, which yields
3 - 6
/|
5 7
And now the tree with 3 at its root contains only 3 elements, so it is not a binomial tree anymore.
Hope this helps!

- 362,284
- 104
- 897
- 1,065