views:

35

answers:

2

Hi this is an example in my data structure book and for this exercise was written that this is not a max heap,but it doesn't say its reason would you please help me that why it is not a max heap thanks.

       35
      /  \
     /    \
    27    28
   / \    / \
  /   \  /   \
 14   16 20   19
A: 

I thought the definition of a (max) heap is that every node is bigger than all its children. And, therefore, the largest value is always at the root and therefore easy to access. This looks like a heap to me!

dty
but it was written that it is not a heap! I do not know why? maybe it relates to binary tree!
Maybe it's wrong? Or maybe you've got the context wrong?
dty
A: 

you should post the entire question, and if that book actually says that this is not a max-heap then stop reading that book :P

Game
this tree is an ordered tree?
because I think that the reason relates to binary tree!