This is in continuation with our previous question (#20).
Question #21: At what level will the next to smallest element be present in a binary max-heap?
Options:
-
Last level only
-
Last or second last level only
-
Depends on the number of levels
-
Depends on the total number of nodes
Solution: The correct answer is 2. Keeping in mind that heap is a full binary tree except the last level, we can see that the next to smallest element can only have 1 child – i.e. the smallest element. Therefore it can only be present at second last level in that case, otherwise it will be present on the last level.