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