| | |
Trees?
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2004
Posts: 1,620
Reputation:
Solved Threads: 51
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:
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
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:
C Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- binary search trees (Java)
- Someone help me hate trees less (Java)
- Help with Tertiary trees?!?! (Java)
- binary trees (C)
Other Threads in the C Forum
- Previous Thread: how to declare two integer variables x and y
- Next Thread: please help me
Views: 1989 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
* api append array arrays bash binarysearch changingto char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax database directory drawing dynamic executable execv feet fgets file floatingpointvalidation fork frequency function functions getlogicaldrivestrin givemetehcodez global graphics gtkwinlinux histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list lowest matrix meter microsoft mqqueue mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked reversing scheduling segmentationfault send single socketprogramming spoonfeeding standard strchr string student suggestions system test testautomation testing unix urboc user whythiscodecausesegmentationfault win32api windowsapi






