This doesn’t seem correct. Since, the tree T1 has million nodes, its prudent to search the root of T2 in T1 first rather than going for preorder (or any for that matter) traversal of T1. Once, you have the searched node in T1; run the algorithm to compare equal trees structurally on T1 and this searched node in T2. When T2 is done, stop in case program didn’t stop earlier. This would be the case of a success.