使用递归更改变量

时间:2013-03-16 03:05:09

标签: java variables recursion

对于二进制搜索树,我只能访问根节点,而我正在尝试编写一个递归方法来挖掘它的左边节点。

例如,

  

root.left();

变为

  

root.left()左();

然后,

  

root.left()左();

你知道这是怎么回事。有没有一种递归方式来改变/添加变量?

1 个答案:

答案 0 :(得分:2)

这样的东西?

Node node = root;
while (someCondition) {
    node = node.left();
    // do something with the node
}