in language C
Code that examine if the tree is full
Tree is full if each node have 2 child
i dont know how to write the code ?
somebody can help me ?

>i dont know how to write the code ?
Do you know how to do a preorder traversal? Once you have that, it's just a test whether both children are either null or not null. It's a short solution, so I can't give you example code without solving the problem for you.

in language C
Code that examine if the tree is full
Tree is full if each node have 2 child
i dont know how to write the code ?
somebody can help me ?

It seems to me a tree can never be full. The last node(s) will always have two free child positions, won't it?

>The last node(s) will always have two free child positions, won't it?
A full tree in this case is one where every non-leaf node has two non-null children. For example:

a
     /   \
    b     c
   / \   / \
  d   e f   g

is a full tree, but

a
     /   \
    b     c
     \   / \
      e f   g

is not because b is neither a leaf nor has two non-null children.

>The last node(s) will always have two free child positions, won't it?
A full tree in this case is one where every non-leaf node has two non-null children.

{pictire snipped] is not because b is neither a leaf nor has two non-null children.

Oh... OK. I didn't realize that was a definition. Thanks.

This article has been dead for over six months. Start a new discussion instead.