Can someone explain to me what a binary tree is, where, why and how I would use one??
Printable View
Can someone explain to me what a binary tree is, where, why and how I would use one??
Its a structure where each item in the structure has two children.
Each item can hold a value, perhaps a string or number, and each value has not more than two values under it.
They are used mainly in sorting/indexing and are not something you would normally use in everyday vb6 programming. They are more associated with low level C++ programming, where you are doing somthing like sorting or indexing a lot of random data.
By storing the data in a tree, instead of in a linear format, it is faster to find things. You just go down the branches of the tree, branching off in the right direction until you find what you want. This is faster than going through a file from one end to the other.
http://www.cs.jhu.edu/~goodrich/dsa/trees/btree.html
is an animated binary tree (written in java I guess) that shows the concept quite well.
These may be good starting points
http://webopedia.lycos.com/TERM/B/binary_tree.html
http://www.scism.sbu.ac.uk/jfl/Chapter15/chap15p6.html
Take a look at these links as well... :)
http://www.freevbcode.com/ShowCode.Asp?ID=3309
http://www.freevbcode.com/ShowCode.Asp?ID=1602
http://www.vbwm.com/art_2001/avltree08/
You could also check a Binary Tree in a program, here I add it. :)