I'm designing a scene graph system, where it is required to compare two trees. The trees are populated with individual objects, each with varied number of children; and they have a root.Eg: Parent: Scene, Children: Bullet1, Bullet 2, Player  What is a good way to compare two such tree? I'm using C++ for the code.Also, this question is an off-shoot from this question
Efficient way to compare scene-graph trees
c++;comparison;graphics;trees
Create a stack of node pairs for in-depth comparison.Define an identifier you can use for quick comparison e.g. ID/name/model-path.Shallow compare root nodes, if they match add them to stack.For each pair in stack:2.1. Sort children according to chosen identifier2.2. Shallow compare children and add matches to stack.Decide whether algorithm should be terminated on first mismatch or not (depending on required results).If your nodes are themselves sub-trees (of smaller parts), you can apply the same algorithm to them.