If a binary tree is both a max-heap and an AVL tree, what is its largest possible number of nodes, assuming all keys are different?
The number of nodes in a binary tree
binary trees;heaps
I'm going to say 2.A max-heap is a near-complete binary tree. This means any child must have a key less than it's parent's key.An AVL tree is a balanced binary search tree. This means the left child must have a key less than it's parent and the right child must have key greater than it's parent.From these, You can see that there can be no right-children in the tree. Hence, You can only have left-children. Since the max-heap has the near-complete property, The largest tree you can have is the root node with a left-child.Hence, The maximum size is 2.