More on balanced trees
Earlier we studied balanced binary search trees, such as AVL trees, that relied
on rotation for balancing trees that were only one-level
away from balance. An alternative method for balancing
is to use multi-way branching trees like B-Trees or 2-3 Trees.
Key properties to multiway balanced trees are:
- Branching nodes in the same tree can have different
branching factors. In a binary search tree every brancing
node has a brancing factor of 2.
- For a node with branching factor of n, there are (n-1)
key values, and the values in nodes in sub trees obey
invariants about which relate to the key values.
- There is an upper bound to the branching factor. When the upper
bound is reached, the node is split into 2-nodes each with roughly
one half the branching factor.
- Trees are balanced by adjusting the branching factor or some of the nodes
in a tree that is only slightly out of balance.
A multi-way balance tree of order n has a maximum branching
factor of n.
Two common kinds of multiway balanced trees are:
- B-Trees.
- Often used in databases, where each node maps to a distinct disk page.
- Since Disk accesses take several orders of magnitude more time to access
than memory accesses, much time can be saved by making the nodes
have a high order, thus making the height of the tree very small.
- The shallower the tree, the fewer disk accesses necessary
and the faster the search.
- Disk drives often read a large amount of data at
a time so this correlates with a large Node size as well.
- 2-3 Trees are multi-way trees with order 3.
- Since the order is small and fixed, the code to
implement them is often simpler.
- Intra-node search is quick since the node size is small.
- Often used for main memory data rather than
data stored on disks.
Back to the Daily Record.
Back to the class web-page.