next up previous
Next: Up: Previous:

Operations

*
Decrease-Key(H, x, k), where k $\leq$ key(x)

Decrease-Key(H, x, k)
$\;\;\;\;\;$key(x) = k
$\;\;\;\;\;$while parent(x) $\neq$ NIL and key(x) < key(parent(x))
$\;\;\;\;\;$ $\;\;\;\;\;$;; "bubble" new key up
$\;\;\;\;\;$ $\;\;\;\;\;$swap(key(x), key(parent(x)))
$\;\;\;\;\;$ $\;\;\;\;\;$x = parent(x)



Max depth = \(\lfloor \lg n \rfloor\)
Running time = O(lg n)

*
Delete(H, x)

Delete(H, x)
$\;\;\;\;\;$Decrease-Key(H, x, $-\infty$) $\;\;\;\;\;$ $\;\;\;\;\;$; O(lg n)
$\;\;\;\;\;$Extract-Min(H) $\;\;\;\;\;$ $\;\;\;\;\;$ $\;\;\;\;\;$ $\;\;\;\;\;$; O(lg n)



Running time = O(lg n)

Binomial Heap Example


next up previous
Next: Up: Previous: