Also called Decrease-key, Increase-key, Change-key and Priority update.
fresh numbers
The test's questions that a run answers, asked again on new numbers whenever you like. The answer, its working and the reason for every other choice come from changing a number in a heap's own run on the numbers shown.
choose one
1question 1
The heap drawn was made by putting in 16, 29, 23, 47, 35, 40 and 31. Then 23 changes to 50. At which place does 50 stop?
the answer, and why
the answer is B
23 stands at place 3, over 40 and 31. 50 is bigger than both, so it swaps with the smaller, 31, down to place 7, which has no child.
step 16 of 22
23 stands in place 3. The heap keeps a note of where each number stands, so this is one look and no comparison.
comparisons: 0
step 20 of 22
Swap them: 50 sinks below 31.
comparisons: 2
step 21 of 22
Nothing is below 50, so it stays.
comparisons: 2
23 at place 3 becomes 50, sinks below 31, the smaller child, and stops. 2 comparisons.
if you chose another
AThat swaps with 40, the first child. A sink swaps with the smaller child, 31.
CThat leaves 50 over 40 and 31, both smaller than it.
DPlace 2 is not below place 3. Place 3's children are places 6 and 7.
Each list puts 11 to 17 into an empty heap, smallest first, then makes one change; 11->20 means change 11 to 20. Which list makes the most comparisons?
the answer, and why
the answer is A
With 11->20, the top made 20 sinks two levels, comparing both children at each, 4 comparisons; the others cost 2. With the puts' 6, 11->20 costs 6 + 4 = 10, the others 6 + 2 = 8.