Would anyone know how to draw a binomial max heap for values 1-10? I am currently learning about heaps in my Data Structure course, but after watching multiple videos I still can't get it! And I am not sure if I am doing it right.
I understand that binomial heaps connect with their past ones, but I am stuck on max ones specifically. I hope that by drawing it and seeing the end result I will have a better understanding.
Here is my implementation (each 'return' is a new level
10
9 8 6 (all 3 numbers connected to 10)
7 5 4 (7 connected to 8, 5 & 4 connected to 6)
2 1 3 (2 connected to 7, 1 to 5, 3 to 4)
I was unsure where to put the 1 and 2.
Please let me know if I should improve my question somehow and if needed. Thank you!
According to the tag info, a binomial heap is a forest of binomial trees. And according to this wikipedia article, the number of elements in each tree must always be a power of 2. Furthermore, there can only be one tree of each size. So, for example, if there are two trees of size 4, then they need to be combined into a single tree of size 8.
So a binomial heap with 10 elements consists of two trees: a tree with 8 elements, and a tree with 2 elements. Which means your heap is as shown below. The 1 and 2 aren't connected to the other eight elements. They are in a separate tree.
The dotted lines can be ignored. The image source is the wikipedia article, and I just filled in the numbers.