944,001 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1538
  • C RSS
Dec 15th, 2006
0

How to examine if the tree is full

Expand Post »
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 ?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
hugoboss2 is offline Offline
1 posts
since Dec 2006
Dec 15th, 2006
0

Re: How to examine if the tree is full

>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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Dec 15th, 2006
0

Re: How to examine if the tree is full

Click to Expand / Collapse  Quote originally posted by hugoboss2 ...
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?
Moderator
Reputation Points: 3278
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006
Dec 15th, 2006
0

Re: How to examine if the tree is full

>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:
  1. a
  2. / \
  3. b c
  4. / \ / \
  5. d e f g
is a full tree, but
  1. a
  2. / \
  3. b c
  4. \ / \
  5. e f g
is not because b is neither a leaf nor has two non-null children.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Dec 16th, 2006
0

Re: How to examine if the tree is full

Click to Expand / Collapse  Quote originally posted by Narue ...
>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.
Moderator
Reputation Points: 3278
Solved Threads: 894
Posting Sage
WaltP is offline Offline
7,747 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: recursive backtracking
Next Thread in C Forum Timeline: USB webcam support in C(running under LINUX)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC