C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Binary trees

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Fri May 04, 2007 4:55 am    Post subject: Binary trees Reply with quote



- with 10 nodes, give one example of an unbalanced binary tree and
one example of a balanced binary tree
- what is the advantage of having a balanced binary tree over an
unbalanced tree?
- number your nodes, then give the order in which nodes will be
visited by a depth-first-search
- explain the differences between traversing the tree pre-order, in-
order and post-order
Back to top
Dave Vandervies
Guest





PostPosted: Fri May 04, 2007 4:55 am    Post subject: Re: Binary trees Reply with quote



In article <1178236539.346703.194270 (AT) h2g2000hsg (DOT) googlegroups.com>,
<n.noumia (AT) gmail (DOT) com> wrote:
Quote:
- with 10 nodes, give one example of an unbalanced binary tree and
one example of a balanced binary tree

Example of a balanced binary tree: [IMAGE]
Example of an unbalanced binary tree: [IMAGE]

Quote:
- what is the advantage of having a balanced binary tree over an
unbalanced tree?

A balanced tree won't fall over when you stop holding it.

Quote:
- number your nodes, then give the order in which nodes will be
visited by a depth-first-search

42, pi, 17, e, 105, 69, i, sqrt(2), 3, -1.

Quote:
- explain the differences between traversing the tree pre-order, in-
order and post-order

The order you traverse it in is different.

DYODH.



dave

--
Dave Vandervies dj3vande (AT) csclub (DOT) uwaterloo.ca
Hey, I can beat him on the Impressive But Useless certificates thing.
I have a PhD.
--Dan Holdsworth in the scary devil monastery
Back to top
Eric Sosman
Guest





PostPosted: Fri May 04, 2007 7:56 am    Post subject: Re: Binary trees Reply with quote



n.noumia (AT) gmail (DOT) com wrote:
Quote:
- with 10 nodes, give one example of an unbalanced binary tree and
one example of a balanced binary tree

Unbalanced tree: AB,C'KVery Happy'EH:FJ:G: (notation adapted
from Knuth, TAOCP 2.3.3 equation 3)

To balance the tree, put another one on the other pan.

Quote:
- what is the advantage of having a balanced binary tree over an
unbalanced tree?

Easier access to firewood. When the next high wind topples
the unbalanced tree, the balanced tree that's over it will fall
at the same time and save you the work of cutting it down.

Quote:
- number your nodes, then give the order in which nodes will be
visited by a depth-first-search

Numbers: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

Depth-first order: 1, 1, 1, 1, 1, 1, 1, 1, 1, 1

Quote:
- explain the differences between traversing the tree pre-order, in-
order and post-order

With pre-order, the pizza is ready when you arrive at the
shop and you needn't wait. With in-order, you may need to pay
a restaurant tax to eat the pizza on the premises. With post-
order, the pizza reaches you three to five business days later
and is unpalatable.

--
Eric Sosman
esosman@acm-dot-org.invalid
Back to top
Chris Dollin
Guest





PostPosted: Fri May 04, 2007 9:12 am    Post subject: Re: Binary trees Reply with quote

n.noumia (AT) gmail (DOT) com wrote:

Quote:
- with 10 nodes, give one example of an unbalanced binary tree and
one example of a balanced binary tree
- what is the advantage of having a balanced binary tree over an
unbalanced tree?
- number your nodes, then give the order in which nodes will be
visited by a depth-first-search
- explain the differences between traversing the tree pre-order, in-
order and post-order

I think you should have posted to comp.lazy.domyhomework, since (a)
this is homework; having someone else do it for you misses the point;
(b) it's off-topic, since it isn't about C at all.

--
Not A Number, A Free Hedgehog
Meaning precedes definition.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C Language All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.