Purchase Solution

C++ program to determine structurally identical binary trees

Not what you're looking for?

Ask Custom Question

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.

Attachments
Purchase this Solution

Solution Summary

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.

Solution Preview

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 ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C# variables and classes

This quiz contains questions about C# classes and variables.