How to examine if the tree is full

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2006
Posts: 1
Reputation: hugoboss2 is an unknown quantity at this point 
Solved Threads: 0
hugoboss2 hugoboss2 is offline Offline
Newbie Poster

How to examine if the tree is full

 
0
  #1
Dec 15th, 2006
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 ?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,730
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 737
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: How to examine if the tree is full

 
0
  #2
Dec 15th, 2006
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: How to examine if the tree is full

 
0
  #3
Dec 15th, 2006
Originally Posted by hugoboss2 View 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 ?
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 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,730
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 737
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: How to examine if the tree is full

 
0
  #4
Dec 15th, 2006
>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.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: How to examine if the tree is full

 
0
  #5
Dec 16th, 2006
Originally Posted by Narue View Post
>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.
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC