Can the same node appear twice in a tree?
I’m asking about the node object itself, not the node’s value. For example, in the following code, a’s left and right are the same node, b.
a = new TreeNode(1) b = new TreeNode(2) a.left = b; a.right = b;
Is this valid? Why or why not?