In: Computer Science
Prove the following:
When replacing the key in a node of a heap with a key that is greater than one, or greater than both, of its children, then sifting that node down (trading places with its smallest child) until it is less than all of its children will produce a heap.
When replacing the key in a node of a heap with a key that is greater than one, or greater than both, of its children, then sifting that node down (trading places with its smallest child) until it is less than all of its children will produce a heap.
The proof is shown below considering a general heap: