1、Binomial heap In computer science, a binomial heap is a heap similar to a binary heap but also supports quick merging of two heaps. This is achieved by using a special tree structure. It is important as an implementation of the mergeable heap abstract data type(also called meldable heap), which is a
2、 priority queue supporting merge operation. Binomial tree A binomial heap is implemented as a collection of binomial trees (compare with a binary heap, which has a shape of a single binary tree). A binomial tree is defined recursively: A binomial tree of order 0 is a single node A binomial tree of o
3、rder k has a root node whose children are roots of binomial trees of orders k1, k2, ., 2, 1, 0 (in this order). Binomial trees of order 0 to 3: Each tree has a root node with subtrees of all lower ordered binomial trees, which have been highlighted. For example, the order 3 binomial tree is connecte
4、d to an order 2, 1, and 0 (highlighted as blue, green and red respectively) binomial tree. A binomial tree of order k has 2k nodes, height k. Because of its unique structure, a binomial tree of order k can be constructed from two trees of order k1 trivially by attaching one of them as the leftmost c
5、hild of root of the other one. This feature is central to the merge operation of a binomial heap, which is its major advantage over other conventional heaps. The name comes from the shape: a binomial tree of order has nodes at depth . Structure of a binomial heap A binomial heap is implemented as a
6、set of binomial trees that satisfy the binomial heap properties: Each binomial tree in a heap obeys the minimum-heap property: the key of a node is greater than or equal to the key of its parent. There can only be either one or zero binomial trees for each order, including zero order. The first prop
7、erty ensures that the root of each binomial tree contains the smallest key in the tree, which applies to the entire heap. The second property implies that a binomial heap with n nodes consists of at most logn + 1 binomial trees. In fact, the number and orders of these trees are uniquely determined b
8、y the number of nodes n: each binomial tree corresponds to one digit in the binary representation of number n. For example number 13 is 1101 in binary, , and thus a binomial heap with 13 nodes will consist of three binomial trees of orders 3, 2, and 0 (see figure below). Example of a binomial heap containing 13 nodes with distinct keys. The heap consists of three binomial trees with orders 0, 2, and 3.