Trees?

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

Join Date: Aug 2004
Posts: 140
Reputation: chound is an unknown quantity at this point 
Solved Threads: 1
chound chound is offline Offline
Junior Poster

Trees?

 
1
  #1
Sep 4th, 2004
What are trees?
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 1,620
Reputation: kc0arf is a jewel in the rough kc0arf is a jewel in the rough kc0arf is a jewel in the rough 
Solved Threads: 51
Team Colleague
kc0arf kc0arf is offline Offline
Posting Virtuoso

Re: Trees?

 
1
  #2
Sep 7th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 11
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: Trees?

 
0
  #3
Sep 7th, 2004
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.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC