Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer with c++! I need bintree.h and bintree.cpp test main.cpp // presumably bintree.h includes nodedata.h so the include is not needed here #include bintree.h

Please answer with c++! I need bintree.h and bintree.cpp

image text in transcribedimage text in transcribed

test main.cpp

// presumably bintree.h includes nodedata.h so the include is not needed here #include "bintree.h" #include  #include  using namespace std; const int ARRAYSIZE = 100; //global function prototypes void buildTree(BinTree&, ifstream&); // build the tree using given data file void initArray(NodeData* []); // initialize an array elements to nullptr int main() { // create file object infile and open it // for testing, call your data file something appropriate, e.g., data2.txt ifstream infile("data2.txt"); if (!infile) { cout  and: "  not: "  sss: " > s; cout  

test output

Initial data: iii not tttt eee r not and jj r eee pp r sssss eee not tttt ooo ff m m y z $$ Tree Inorder: and eee ff iii jj m not ooo pp r sssss tttt y z z y tttt sssss r pp ooo not m jj iii ff eee and Retrieve --> and: found Retrieve --> not: found Retrieve --> sss: not found Sibling of and: ff Sibling of not: eee Sibling of sss: notFound Parent of and: eee Parent of not: iii Parent of sss: notFound T == T2? equal T != first? equal T == dup? equal z y tttt sssss r pp ooo not m jj iii ff eee and --------------------------------------------------------------- Initial data: b a c b a c $$ Tree Inorder: a b c c b a Retrieve --> and: not found Retrieve --> not: not found Retrieve --> sss: not found Sibling of and: notFound Sibling of not: notFound Sibling of sss: notFound Parent of and: notFound Parent of not: notFound Parent of sss: notFound T == T2? equal T != first? not equal T == dup? not equal c b a --------------------------------------------------------------- Initial data: c b a $$ Tree Inorder: a b c c b a Retrieve --> and: not found Retrieve --> not: not found Retrieve --> sss: not found Sibling of and: notFound Sibling of not: notFound Sibling of sss: notFound Parent of and: notFound Parent of not: notFound Parent of sss: notFound T == T2? equal T != first? not equal T == dup? not equal c b a --------------------------------------------------------------- Initial data: 
Create a binary search tree class called BinTree (has additional non-BST functions). The NodeData object is stored once in the tree. The tree class is not tied to any particular type of data beyond NodeData as containers don't know about the data they hold. You must use a tree node which holds a NodeData* for the data (along with the left and right pointers). To test your tree class, NodeData holds one string. A data file consisting of many lines is used to build binary trees. One line, which consists of many strings, are used to build one tree, terminated with the string "\$\$". Sample input iii not tttt eee r not and jj r eee pp r sssss eee not tttt ooo ff mm y z $ The internal tree built woul: Lab requirements and output includes the following. -- A default constructor (initially creates an empty tree), a copy constructor, and destructor (calls interface makeEmpty - Overloaded operator=, operator==, and operator!=. You would not use insert for the copy constructor or operator=. Right?? Make sure that you understand that it is inefficient to use insert, i.e., think complexity of using insert and not using insert. Define two trees to be equal if they have the same data and same structure. For example, -- The operators // you add class/method comments and assumptions/implementation public: Bintree () ; Bintree (const Bintree \&); Bintree(); // calls makeEmpty() bool isempty () const; void makeEmpty(); // delete all memory so isempty() returns true Bintree & operator =( const Bintree &); bool operator=e(const Bintree \&) const; bool operator!=(const Bintree \&) const; bool insert (NodeData*) ; bool retrieve (const NodeData\&, NodeData*\&) const; bool remove (const NodeData \&, NodeData* ); void displaysideways() const; // displays the tree sideways, root is leftmost and so on ... private: struct Node 1 NodeData* data; // pointer to data object Node* left; // left subtree pointer Node* right; 1/ right subtree pointer \} ; Node* root; // root of the tree // utility functions void inorderHelper ( ...) const; // recursive helper for operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What is transaction integrity? Why is it important?

Answered: 1 week ago