My goal, given two binary trees, is to return true if they are structurally identical, meaning they are made of nodes with the same values arranged in the same way.
Each line of values in input file "tree2Data.txt" represents one linear binary tree, where ' _ ' represents a no value node.
Compare all trees to all other trees.© BrainMass Inc. brainmass.com December 24, 2021, 10:49 pm ad1c9bdddf
Please go through the attached solution (510302.cpp) that compares all the trees stored in input file (tree2Data.txt) after converting them from linear binary tree representation to normal binary tree representation. Though your input file has only 4 trees, but the attached code is generic in this respect and can handle any number of trees in the input file. One important thing to take care is that the input file should not have any blank lines and it should end with a ...
Solution compares the trees in the input file after converting them from linear binary tree representation to normal binary tree representation. Attached code is quite generic and can handle any number of trees in the input file. Quite likely it is more generic than what you need, so you may need to tweak it down as per your requirement. GNU C++ compiler g++ version 4.3.4 was used during the development of this solution.