Lab 4 Notes
Next Prev Binary Tree
nextAncestor()
- 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
- hint: use
[Example 1]
- Consider node
g
in the following binary tree:
d, b, f, e, g, a, c ? ? ^ -
- What about node
c
?
next()
- returns the next node according to an inorder traversal
[Example 2]
- Consider node
b
in the following binary tree:
d, b, f, e, a, c ^ -
- What about
e
?
d, b, f, e, a, c ^ -