Understanding the Need to Sort and Search
As the output shows, the
traverse
function doesn’t print anything until it gets to
the first leaf. It then prints both leaves and the parent of those leaves. The traversal
follows the left branch first, and then the right branch. The root node comes last.
There are different kinds of data storage structures. Here is a quick list of the
kinds of structures you commonly find:
»
Balanced trees: A kind of tree that maintains a balanced structure through
reorganization so that it can provide reduced access times. The number of
elements on the left size differs from the number on the right side by
at most one.
»
Unbalanced trees: A tree that places new data items wherever necessary in
the tree without regard to balance. This method of adding items makes
building the tree faster but reduces access speed when searching or sorting.
Do'stlaringiz bilan baham: |