![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 155
Rep Power: 3
![]() |
trees
how many types of trees are there in c++? maybe one of the types would be binary tree, and then there might be subtypes ...
but basically how many types of trees are there in c++? |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
I wasn't aware of there being different types of tree. A binary tree is a special case, of course, but it's still just a regular ol' tree. That's like saying "How many types of rectangles are there? Maybe one of the types would be squares..."
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials. --WilliamSChips on Slashdot |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Apr 2006
Location: Calgary, Alberta
Posts: 67
Rep Power: 3
![]() |
The special ones I can think of offhand are Binary Trees and Balanced Trees, but there really are about as many tree types as you count.
|
|
|
|
|
|
#4 |
|
Hobbyist Programmer
|
why would some trees be specific to C++? i thought the idea was some what universal in computers science
__________________
i dont know much about programming but i try to help |
|
|
|
|
|
#5 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
Go here and search for tree (and see all the different names for similar or identical structures :o). And as mrynit mentioned, trees aren't specific to C++
|
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 155
Rep Power: 3
![]() |
well .... i am a little confused ....
do binary trees have to store numbers in their nodes? if yes, then how do i build an abstract syntax tree for my parser? i was also thinking about expression trees? .... |
|
|
|
|
|
#7 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,197
Rep Power: 5
![]() |
Heap data structures are often (always?) implemented as a form of tree, too.
As for their being more types than binary, it's perfectly possible to have a hypothetical tree where each node had more than two potential child nodes. I can't see it offering any advantage except in very specific circumstances, like perhaps a radix sort, but then there are probably better structures for those purposes (hybrid hash table, for example). Quote:
Two common variants are the binary search tree and the heap. In the former, nodes are added/removed in such a manner that the child node that is 'less than' a parent node is on one branch, and the child node that is 'greater than' the parent is on the other branch. This is done in recursive fashion (so a child on a 'less than' node is less than its parent, and the parent's parent, and so on), and because the nodes are objects, the programmer defines the semantics of less than/greater than. This form of a tree is intended to gain the benefits of a linked list without the heavy performance penalties of arbitrary additions to the list. In the latter, the nodes are added/removed in such a way that the 'largest' (or smallest) is always on top. Again, what defines 'largest' is up to the programmer. This type of tree is often used for priority queues (where the item with highest importance gets processed first).
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick Last edited by lectricpharaoh; Jul 20th, 2006 at 3:51 AM. |
|
|
|
|
|
|
#8 | |
|
Hobbyist Programmer
Join Date: Feb 2006
Posts: 155
Rep Power: 3
![]() |
Quote:
|
|
|
|
|
|
|
#9 | |
|
SEXY SHOELESS GOD OF WAR!
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,197
Rep Power: 5
![]() |
Quote:
Also, reread my post above. I started editing it in between when I first posted it, and when you read/replied to it, and added some more info.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#10 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
Um, I am actually in the middle of writing a program that revolves around a tree that is not binary.
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials. --WilliamSChips on Slashdot |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning an array of lists | deanosrs | C | 42 | Apr 13th, 2006 2:35 PM |
| Moving directory trees via .bat files | Mansooj | Bash / Shell Scripting | 11 | Jan 17th, 2006 3:45 AM |
| Flattening Trees Into Arrays | Will Piovano | C | 2 | Nov 11th, 2005 9:00 AM |
| Trees & Checkboxes | quants | Delphi | 0 | Apr 18th, 2005 11:18 AM |