- More terms.
- A path through a binary tree is a sequence of edge traversals
through the tree.
- Usually starting at the root, but not necessarily.
- Usually obeying the edge direction, but not necessarily.
- The length of a path (or just path length or just
length) is the number of nodes in the path.
- This could be one for a path that doesn't go anywhere.
- Sometimes length refers to the number of edges instead.
- This can result in off-by-one errors.
- A binary tree's height is the length of the longest path starting
at the root.
- This is sometimes called the tree's depth too.
- The interface.
- The usual suspects
add()
, remove()
, find()
, and empty()
.
- Traversal functions are also useful:
left_child()
and
right_child()
.
- The implementation.
- We can exploit the equivalence between binary trees and linked lists.
- But now binary trees are no better than linked lists, which misses
the point.
This page last modified on 3 December 2003.