Purchase Solution

C++ Binary Tree to handle single word data

Not what you're looking for?

Ask Custom Question

My goal is to develop some binary tree routines in C++ that will handle single word data. The binary tree will be maintained as an ordered tree.

The routines I need are:

Add - add a new word to tree (do not allow duplicates).
Search - look up a word in the tree and indicate if the word is in the structure or not.
Traverse (in-order, pre-order, post-order) - label tree output with traversal order used to print the tree.

Attached is the input file. The commands should be executed in the order given. Where it says an order type such as inorder, that means to print the tree so far, in that way.

I have code for a lot of this but it needs checking. I do not have much experience with string functions, so try to use them as less as possible.

Purchase this Solution

Solution Summary

Solution is hardly using any string functions apart from string usages like "infile >> stringvar", "cout << stringvar", "stringvar comparisonoperator somevalue".

Solution Preview

Please find attached 508716.cpp that fixes your existing code and adds processing of treeinput.txt commands to it. Please compare it with your existing code, so that you know where you went wrong and how close you were to right code.

Output generated by the fixed program is pasted below for your cross-checking. Please let me know if you do not understand anything in the fixed code or find any error/issue.

Processing commands from 'treeinput.txt'

Adding kindness ...
Adding rascal ...
Adding structures ...
Adding man ...
Adding forest ...
Adding mice ...
Adding manoman ...
Adding until ...
Adding rascals ...
Adding yahoo ...
Adding jack ...
Adding jammers ...
Adding kindman ... ...

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Javscript Basics

Quiz on basics of javascript programming language.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

C# variables and classes

This quiz contains questions about C# classes and variables.

C++ Operators

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