Suppose that you have a binary tree, but you do not trust it, and you think that it can be a graph, the general case will dictate to remember the visited nodes. To some extent, this is the same algorithm as building a minimal spanning tree from a graph, and this means that the problem with space and time will be a problem.
Another approach would be to look at the data that you save in the tree. You have a number of hashes so you can compare.
Pseudocode will check these conditions:
- node 2 1 ( 3 ). 3 = > .
- .
node , , , . , , node node (, ), . node, , , , , .
3.a. , , , . So = > . .
, , ? , node . . , , , .