views:

797

answers:

3

Hi,

Here's the binary tree in question, poor quality image I know but hopefully it's legible. The leaves are a,b,c,d and the edges are labelled 0 or 1.

EDIT: Transcripted tree

    .
   / \
  a   .
     / \
    b   .
       / \
      c   d

It seems to me that it is a full binary tree, as every node is either a leaf or has two child nodes, however I have this feeling that we were told it is not a full binary tree. If not, why is it not?

If a node has a child that is a leaf, does that not count as a child node?

Thanks,

Adam

+4  A: 

You are confusing a perfect binary tree with a full binary tree. A perfect binary tree is a full binary tree with all leaf nodes at the same level. So yes, the picture is a full binary tree.

A leaf is defined as a node without a child node.
Thus, a full binary tree is a binary tree in which each node has either zero or two children.

Wikipedia helps very well with definitions. Make sure you check it out.

Mehrdad Afshari
I was going to say that it is not balanced. But thanks for a new definition. You learn something everyday.
uriDium
Balanced is another story. It means depth difference between right and left child of each node is at most one.
Mehrdad Afshari
Shouldn't that be "So yes, the picture is a **perfect** binary tree"?
sharkin
No. The picture doesn't satisfy the condition I said. A perfect binary tree of depth N will have (2^N - 1) nodes.
Mehrdad Afshari
A: 

It is a binary tree - each node has at most two children.

Prashast
A: 

Yes, a tree with each node has zero or two children, it is binary tree.

Eyhel-Chiu