Finding the minimum key The procedure BINOMIAL-HEAP-MINIMUM returns a pointer to the node with the minimum key in an n-node binomial heap H. This implementation assumes that there are no keys with value ∞.
BINOMIAL-HEAP-MINIMUM(H) 1 y ← NIL 2 x ← head[H] 3 min ← ∞ 4 while x ≠ NIL 5 do if key[x] < min 6 then min ← key[x] 7 y ← x 8 x ← sibling[x] 9 return y
Since a binomial heap is min-heap-ordered, the minimum key must reside in a root node. The BINOMIAL-HEAP-MINIMUM procedure checks all roots, which number at most⌊lg n⌋ + 1, saving the current minimum in min and a pointer to the current minimum in y.
Analysis:- Because there are at most ⌊lg n⌋ + 1 roots to check, the running time of BINOMIAL-HEAP MINIMUM is O(lg n). operations-on-binomial-heap.php
This free website was made using Yola.
No HTML skills required. Build your website in minutes.