Adam Taylor
Adam Taylor

Reputation: 7783

Is this a full binary tree?

Here's the binary tree in question. The leaves are a, b, c, d and the edges are labelled 0 or 1.

    .
   / \
  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?

Upvotes: 2

Views: 2142

Answers (2)

Eyhel-Chiu
Eyhel-Chiu

Reputation: 21

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

Upvotes: 2

Mehrdad Afshari
Mehrdad Afshari

Reputation: 421968

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.

Upvotes: 5

Related Questions