























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























Daniel Biediger (Dan)
Remember? Complete tree
Heap with letters 'A' .. 'J'
C A T 50 20 18 30 10 Are these heaps?
Is this a heap?
Shape property is restored. Can order property be restored? How?
If the root is not a leaf node If the value of the root is smaller than its largest child Swap the value of the root with the value of this child. HeapDown the subtree with the new root value. Why just compare the root with its children? How about the rest of the tree? (^) Base Cases (^) The root of the current subtree is a leaf node. (^) The value of the root is greater or equal to the values in both its children.