Wednesday, June 18, 2008


Decrease-key (H, x, k)

The above Procedure decreases a key value of node x to the key ‘k’, in a given heap, H.
Step 1 Is greater ?
if (k > key [x]) then
message : “new key is greater than current key”.
else goto step 2
Step 2 Initialization
set key [x]  k
set y  x
set z  Parent [y]
Step 3 Adjusting the node at proper position, loop
while ((z  Nil) and (key [y] < key [z])
set key [y]  key [z]
set y  z
set z  Parent [y]
Step 4 Return at the point of all

No comments: