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