943,369 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2534
  • C RSS
Sep 4th, 2004
1

Trees?

Expand Post »
What are trees?
Similar Threads
Reputation Points: 15
Solved Threads: 1
Junior Poster
chound is offline Offline
143 posts
since Aug 2004
Sep 7th, 2004
1

Re: Trees?

Hello,

Trees are plants that grow...

In computers, a tree is usually a binary data structure. There are also tree-like structures with many branches, beyond the two.

It is difficult to answer your question without context however.

Being in programming, you are probably asking about a tree of data storage.

Think about storing 3 numbers in order: 15, 27, 42.

You can write a data structure that has the following information:

  1. struct data {
  2. int number;
  3. pointer prev;
  4. pointer next;
  5. }

So, we can store this in a tree to help our data structure and search times.


15 --- 27 --- 42.

Your code would look at 27 first. Do you need the value smaller than 27? then go left. If you need the greater value, go right. If the value you are looking for is not there, you only looked at two variables instead of three.

This is a very simple example, but should give you the gist of it. Trees are data structures that are tricky to program, but when they are done correctly, searching for information is a lot less time intensive.

Christian
Team Colleague
Reputation Points: 121
Solved Threads: 57
Posting Virtuoso
kc0arf is offline Offline
1,629 posts
since Mar 2004
Sep 7th, 2004
0

Re: Trees?

Just to tag on here, generally a tree is a collection of records (usually called 'nodes' when in a tree) that have a 'parent' and one or more 'children'. Practical examples of trees include organizational charts (President, VP's, Workers), species charts, and anything you can specify as an outline.
Reputation Points: 36
Solved Threads: 11
Posting Pro in Training
Chainsaw is offline Offline
436 posts
since Jun 2004
May 26th, 2010
0
Re: Trees?
Click to Expand / Collapse  Quote originally posted by chound ...
What are trees?
Wow, that kind of clarity triggered my heart attack.

If you see something dividing into two or more, there you have a tree. Trees are good. We all love trees.
Reputation Points: 29
Solved Threads: 24
Posting Whiz in Training
Tellalca is offline Offline
209 posts
since Mar 2010

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: Reading a string in a file
Next Thread in C Forum Timeline: dynamic memory allocator help





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


Follow us on Twitter


© 2011 DaniWeb® LLC