Trees
Steven J.
Zeil
August 3,
2013
Most of the data structures we have looked at so
far have been devoted to keeping a collection of elements in some
linear order.
Trees
Trees are the most common non-linear data
structure in computer science.
- Useful in representing things that naturally
occur in hierarchies
- (e.g., many company organization charts are
trees)
- and for things that are related in a
“is-composed-of” or “contains” manner
- (e.g., this country is composed of states, each
state is composed of counties, each county contains cities, each
city contains streets, etc.)
Trees also turn out to be exceedingly useful in
implementing fast searching and insertion.
- Properly implemented, a tree can be both
searched and inserted into in O(log N) time.
[]