What is the best way to theoretically determine (i.e., without executing it) the circumstances under which a particular recursive tree traversal algorithm will lead to a stack overflow in Java?
To clarify my question, consider the following example. Given a simple binary tree implemented in Java:
public class Node {
private int value;
private Node left;
private Node right;
...
public void inOrder() {
if (left != null) {
left.inOrder();
}
System.out.println(value);
if (right != null) {
right.inOrder();
}
}
}
In this algorithm, the maximum number of nested recursive calls is linear with respect to the depth of the tree. So, how can I determine what is the maximum depth of the tree that will allow the roundabout algorithm (or similar) to complete without throwing an error?
- Xss option, , ?
, , (32 64 ....).
- ?
UPDATE:
, , . .