Definition:Pre-Order Traversal of Labeled Tree
Jump to navigation
Jump to search
Definition
Let $T$ be a binary labeled tree.
Pre-order traversal of $T$ is an algorithm designed to obtain a string representation of $T$.
The steps are as follows:
$\mathtt{Preorder} (T):$
- $n \gets t$, where $t$ is the root node of $T$.
- Output the label of $n$.
- If $n$ is a leaf node, stop.
- Let $T_1$ and $T_2$ be the left and right subtrees of $T$.
- If $n$ has only one child, skip this step. Output $\mathtt{Preorder} (T_1)$.
- Output $\mathtt{Preorder} (T_2)$.
- Stop.
The resulting string will be in Polish notation.
Sources
- 2012: M. Ben-Ari: Mathematical Logic for Computer Science (3rd ed.) ... (previous) ... (next): $\S 2.1.3$: Algorithm $2.8$