script

Saturday, January 12, 2013

6.5-4


Why do we bother setting the key of the inserted node to $-\infinity$ in line 2 of MAXHEAP- INSERT when the next thing we do is increase its key to the desired value?

We need to insert $-\infinity$ MAX-HEAP-INCREASE compares the value to be inserted with existing value so it needs a value. We cant insert any value to satisfy the condition but we have insert the smallest value.

No comments:

Post a Comment