Threading
- Binary tree (without parent pointers) has n+1 null pointers
- If a node has a right child then forward navigation proceeds down
- If a node has null right child pointer then forward navigation proceeds up
- Use the otherwise unused null pointer to point to the next node
- If a node has a left child then reverse navigation proceeds down
- If a node has null left child pointer then reverse navigation proceeds up
- Use the otherwise unused null pointer to point to the previous node
- Threading uses n-1 of the unused pointers to direct
iterator traversals
- The remaining two signify the ends of iteration
- Requires flag system to determine whether a non-null child pointer is part
of the tree structure or a "thread" to a next/previous node
|