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 binary heap's own run on the numbers shown.
choose one
1question 1
The heap drawn was made by putting in 26, 56, 91, 50 and 20; its letters show the order each number came in. Put in 5. What is the row then?
the answer, and why
the answer is D
5 goes in at place 6, under 91. It is smaller, so they swap. Now under 20, it is smaller again, so they swap. At the top, it stays.
if you chose another
AThat stops after one swap, but 5 is still smaller than 20 above it.
BThat leaves 5 where it was put, under 91, which is bigger.
CThat is the whole row in order. A heap only swaps 5 up its way to the top.
How many comparisons do these operations make on an empty heap? 86, 79, 90, 39, then one take.
the answer, and why
the answer is D
86 compares nothing. 79 compares with 86 and climbs to the top. 90 compares with 79 and stays. 39 climbs past 86 and 79, two. The take moves 86 to the top, which meets 79 and 90, two more. 86 swaps below 79, has nothing under it, and stops.
if you chose another
AThat counts the puts only. The take compares too.
BThat counts a comparison each time a number is at the top, but nothing is above it to compare with.
CThat counts one comparison for the take. 86 meets both children of the top.