Reputation: 417
I was working on a problem regarding to binary search tree using java. The name of the built-in class in TreeNode. In the solution, it shows
However, when I did the implementation myself, I am not able to do "root.left" or "root.right". I was wondering if I missed anything? Thanks!
Upvotes: 0
Views: 2875
Reputation: 308
Accessing right/left in that way would imply a TreeNode that is implemented in this way:
public class TreeNode<T> {
public TreeNode<T> right;
public TreeNode<T> left;
public T value;
}
Upvotes: 2