-
A max-heap is a heap where the value of each parent is greater than or equal to the value of its children. Which of the following is a max-heap?
Correct Option: B
A binary tree is max-heap if it is a complete binary tree (A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible) and it follows the max-heap property (value of each parent is greater than or equal to the values of its children).
(a) is not a max-heap because it is not a complete binary tree
(b) is a max-heap because it is complete binary tree and follows max-heap property.
(c) is not a max-heap because 8 is a child of 5 in this tree, so violates the max-heap property.
(d) is not a max-heap because 8 is a child of 5 in this tree, so violates the max-heap property. There are many other nodes in this tree which violate maxheap property in this tree.