Next: bst bnodes iterating level-order, Previous: bst bnodes iterating pre-order, Up: bst bnodes iterating [Index]
Post–order iteration: visit the left–child, then the right–child, then the parent node. As example, given the tree:
5-------10----12 | | | 1--3--4 7--9 11 | | | 2 6 8
the post–order iteration is:
forward: 2, 4, 3, 1, 6, 8, 9, 7, 11, 12, 10, 5 backward: 11, 12, 8, 9, 6, 7, 10, 4, 2, 3, 1, 5
The following syntactic bindings are exported by the library
(vicare containers binary-search-trees)
. The bindings whose
name is prefixed with $
are unsafe operations: they do
not validate their arguments before accessing them.
Like fold-left
for lists, visit the nodes of a binary tree
with a post–order forwards iteration. The argument root must be
#f
to represent an empty tree or an instance of
<binary-node>
representing the root of a tree.
Perform the first step in a post–order forwards iteration. The argument
root must be #f
to represent an empty tree or an instance of
<binary-node>
representing the root of a tree. If the tree is
empty: return #f
; otherwise return an instance of
<binary-node>
representing the first visited node.
Advance an post–order forwards iteration by one step starting from
bnode, which must be an instance of <binary-node>
. If
bnode is the last in the iteration: return #f
; otherwise
return an instance of <binary-node>
representing the next
visited node.
Like fold-right
for lists, visit the nodes of a binary tree with
a post–order backwards iteration. The argument root must be
#f
to represent an empty tree or an instance of
<binary-node>
representing the root of a tree.
Perform the first step in a post–order backwards iteration. The argument
root must be #f
to represent an empty tree or an instance of
<binary-node>
representing the root of a tree. If the tree is
empty: return #f
; otherwise return an instance of
<binary-node>
representing the first visited node.
Advance an post–order backwards iteration by one step starting from
bnode, which must be an instance of <binary-node>
. If
bnode is the last in the iteration: return #f
; otherwise
return an instance of <binary-node>
representing the next
visited node.
Next: bst bnodes iterating level-order, Previous: bst bnodes iterating pre-order, Up: bst bnodes iterating [Index]