Well, now I
realize that the photo of the tree from my previous post would have
been better suited here. Oh well!
Conceptually,
trees are not an incredibly difficult structure to grasp. From a
young age most people have encountered a tree structure of some sort
during their daily lives. Probably the most common and boring example
is arithmetic expressions from math. Even if these are not thought of
by the individual as a tree, they are in fact a type of tree.
Trees obviously
come in many different forms, although I'm mainly interested in the
computer science variety! Trees in computer science are used to
represent structured collections of data. They can be thought of as
an upside-down version of a real tree - with the roots at the top.
Except, instead of having a vast system of roots, a computer science
tree has only one root. From this root there can be any number of
branches, each leading to another smaller tree.
The reason trees
are so useful is their ability to link data together in a meaningful
way. Consider a collection of names. Sure you can store all those
names in a python dictionary or list, but if you store them using a
tree structure, simply the way that they are organized will impart an
extra form of implicit information.
Lets say you
wanted to store all the names belonging to a particular family. You
could contain them within a list, even have them in some kind of
order, but you would essentially just have a list of names. On the
other hand, if you store those names using a tree you could have say
the great grandfather at the top; his children below that, and their
children below that. Hopefully that makes some sort of intuitive
sense, considering that this is type of tree is well known and
refered to as a 'family tree'.
Of course this
description and examples are only the most basic and simplified
versions of trees, but hopefully they illustrate a clear image of
what a Tree is.
No comments:
Post a Comment