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 55, 76, 38, 98 and 8; its letters show the order each number came in. Put in 1. What is the row then?
the answer, and why
the answer is B
1 goes in at place 6, under 55. It is smaller, so they swap. Now under 8, it is smaller again, so they swap. At the top, it stays.
if you chose another
AThat stops after one swap, but 1 is still smaller than 8 above it.
CThat leaves 1 where it was put, under 55, which is bigger.
DThat is the whole row in order. A heap only swaps 1 up its way to the top.
How many comparisons do these operations make on an empty heap? 48, 13, 79, 5, then one take.
the answer, and why
the answer is C
48 compares nothing. 13 compares with 48 and climbs to the top. 79 compares with 13 and stays. 5 climbs past 48 and 13, two. The take moves 48 to the top, which meets 13 and 79, two more. 48 swaps below 13, 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.
DThat counts one comparison for the take. 48 meets both children of the top.