954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Trees?

What are trees?

chound
Junior Poster
145 posts since Aug 2004
Reputation Points: 15
Solved Threads: 1
 

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:

struct data {
 	int number;
 	pointer prev;
 	pointer next;
 }


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

kc0arf
Posting Virtuoso
Team Colleague
1,937 posts since Mar 2004
Reputation Points: 121
Solved Threads: 57
 

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.

Chainsaw
Posting Pro in Training
436 posts since Jun 2004
Reputation Points: 36
Solved Threads: 11
 
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.

Tellalca
Posting Whiz in Training
209 posts since Mar 2010
Reputation Points: 29
Solved Threads: 24
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You