Monthan is write.. Answer: (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 chile of 5 in this tree, so violates the max-heap property. D) is not a max-heap because 8 is a chile of 5 in this tree, so violates the max-heap property. There are many other nodes in this tree which violate max-heap property in this tree.
both a and b are right but i think k heap tree must be complete binary tree so ans is b..is it??
ReplyDeleteI think, No one is a max-heap..
ReplyDeleteright???
@monthan Y u think so??
ReplyDelete@khushbu answers on tomorrow..
both A & B..
ReplyDeleteSory bhai ans is only one.. so do more research on heap tree..
ReplyDeleteyup agree with prashant A & B both.....
ReplyDeleteAnswer is B coz A is not a complete binary tree.
ReplyDeleteMonthan is write..
ReplyDeleteAnswer: (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 chile of 5 in this tree, so violates the max-heap property.
D) is not a max-heap because 8 is a chile of 5 in this tree, so violates the max-heap property. There are many other nodes in this tree which violate max-heap property in this tree.