user355002
user355002

Reputation: 871

max heap and binary tree

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

Upvotes: 0

Views: 1246

Answers (3)

priyanka
priyanka

Reputation: 11

This is a heap tree, but this book is written wrong. Do not follow this book.

Upvotes: 1

AviD
AviD

Reputation: 302

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

Upvotes: 0

dty
dty

Reputation: 18998

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!

Upvotes: 0

Related Questions