- returns the first ancestor that is
next with respect to an inorder traversal
or null if there is none
- hint: use
parent
to go up in the binary tree
- Consider node
g
in the following binary tree:
d, b, f, e, g, a, c
? ? ^ -
digraph BT {
node[fontsize=20];
d, b, f, e, g, a, c;
g [style="filled", fillcolor="green" ]; // myself
e, b, a[style="filled", fillcolor="yellow"]; // my ancestors
a -> b, c;
b -> d, e;
e -> f, g;
}
- returns the next node according to an inorder traversal
- Consider node
b
in the following binary tree:
d, b, f, e, a, c
^ -
digraph BT {
node[fontsize=20];
d, b, f, e, g, a, c;
g[style=invis];
a -> b, c;
b -> d, e;
e -> f;
e -> g[style=invis];
}
d, b, f, e, a, c
^ -