Question: binSTree.h #ifndef BINSTREE_H #define BINSTREE_H #include binTree.h #include binTreeNode.h template class binSTree : public binTree { public: void insert ( const T& x ); //

binSTree.h

#ifndef BINSTREE_H

#define BINSTREE_H
#include "binTree.h"
#include "binTreeNode.h"
template
class binSTree : public binTree
{
public:
void insert ( const T& x ); // insert node with value x
bool search ( const T& x ) const; // searches leaf with value x
bool remove ( const T& x ); // removes leaf with value x
private:
void insert ( binTreeNode *&, const T& ); // private version of insert
bool search ( binTreeNode *, const T& ) const; // private version of search
binTreeNode * remove ( binTreeNode *, const T& ); // private version of remove
bool leaf ( binTreeNode * node ) const; // checks if node is leaf
};
// insert node with value x
template
void binSTree::insert ( const T& x )
{
insert( this->root, x );
}
// searches leaf with value x
template
bool binSTree::search ( const T& x ) const
{
return search( this->root, x );
}
// removes leaf with value x
template
bool binSTree::remove ( const T& x )
{
if( this->size() == 1 )
{
this->root = NULL;
return false;
}
if( this->size() > 1 )
{
if( search( x ) ) this->root = remove( this->root, x );
return true;
}
else if( this->size() == 1 )
{
return false;
}
else
{
return false;
}
}
// private version of insert
template
void binSTree::insert ( binTreeNode *& p, const T& v )
{
if(p == NULL)
{
p = new binTreeNode( v );
}
else if( v < p->data)
{
insert( p->left, v );
}
else if( v > p->data )
{
insert( p->right, v );
}
else
{
return; // duplicate
}
}
// private version of search
template
bool binSTree::search ( binTreeNode * p, const T& v ) const
{
if( p == NULL ) return false;
else
{
if( v == p->data )
{
if( leaf( p ) ) return true;
else return false;
}
else if( v < p->data )
return search( p->left, v );
else
return search( p->right, v );
}
}
// private version of remove
template
binTreeNode* binSTree::remove ( binTreeNode * p, const T& v )
{
binTreeNode* curr;
binTreeNode* parent;
curr = p;
while( curr != NULL )
{
if( curr->data == v )
{
break;
}
else
{
parent = curr;
if( v > curr->data ) curr = curr->right;
else curr = curr->left;
}
}
if( curr != NULL )
{
if( parent->right == curr ) parent->right = NULL;
else parent->left = NULL;
delete curr;
curr = NULL;
}
if( this->size() >= 1 )
{
return this->root;
}
return this->root;
}
// checks if node is leaf
template
bool binSTree::leaf ( binTreeNode * p ) const
{
if( p->left == NULL && p->right == NULL )
{
return true; // node is a leaf
}
else
{
return false; // node is not a leaf
}
}
Getting these errors please help

prog7.cc: In instantiation of void print_vals(binSTree&) [with T = int]: prog7.cc:73:23: required from here prog7.cc:49:10: error: class binSTree has no member named inorder; did you mean inOrder? tree.inorder ( print ); cout << endl; ~~~~~^~~~~~~ inOrder

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!