
Is a tree a heap?
Hey guys, I'm studying for an exam, and have come across the assignment to check if a binary tree is a heap (Heap (data structure)  Wikipedia, the free encyclopedia).
The tree is represented like this:
Code:
public class TreeNode {
public TreeNode parent, left, right;
}
Now, my first idea was simple, if I come across a node that doesn't have a left ancestor (root.left == null), return (root.right == null), but a few runs with pen and paper soon disproved this theory. It's kinda unnerving since identifying the structure of a heap is so easy by looking at it, but I've been coding for some time and haven't come up with a solution. Of course, I'm not looking for a complete solution, nor any bit of code. Just a nudge in the right direction, some property I can use to solve this.