Reputation: 477
For a Binary Search Tree, I only have access to the root node, while I am trying to write a recursive method to dig into its left nodes.
For example,
root.left();
becomes
root.left().left();
and then,
root.left().left();
You see where this is going.. Is there a recursive way to change/add on to the variable?
Upvotes: 0
Views: 68
Reputation: 15523
Something like this ?
Node node = root;
while (someCondition) {
node = node.left();
// do something with the node
}
Upvotes: 2