Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#include BinaryTreeNode.h #include BinaryTree.h #include BSTree.h #include iostream using namespace std; int main ( ) { / / To Do / /
#include "BinaryTreeNode.h
#include "BinaryTree.h
#include "BSTree.h
#include "iostream"
using namespace std;
int main
To Do
Write your code in the main function
Do not use any global variables
cout "Tree : endl;
BSTree myBstTree;
return ;
#pragma once
#include"BinaryTreeNode.h
using namespace std;
template
class BSTree : public BinaryTree
protected:
BinaryTreeNode
root;
root of tree
public:
BSTree
: root
NULL
;
BSTree
const BSTree&
;
BSTree
T data
root
new BinaryTreeNode
data
;
;
virtual ~BSTree
if
root
delete root;
;
BinaryTreeNode
getRoot
return root;
T findSmallest
BinaryTreeNode
nodep
;
virtual bool insert
BinaryTreeNode
nodep const T& x
;
virtual const T
const search
BinaryTreeNode
nodep const T& x
;
virtual bool remove
BinaryTreeNode
nodep const T& x
;
;
template
T BSTree::findSmallest
BinaryTreeNode
nodep
if
nodep
GetLeftChild
nullptr
return findSmallest
nodep
GetLeftChild
;
This is the data contained within the smallest node
return nodep
GetData
;
template
const T
const BSTree::search
BinaryTreeNode
nodep const T& x
if
nodep
return NULL;
if
x
nodep
GetData
return &
nodep
GetData
;
if
x
nodep
GetData
return search
nodep
GetLeftChild
x
;
else
return search
nodep
GetRightChild
x
;
template
bool BSTree::insert
BinaryTreeNode
nodep const T& x
To Do: Write your code here
template
bool BSTree::remove
BinaryTreeNode
nodep const T& x
To Do: Write your code here
You need to complete a BSTree
Binary Search Tree
class in the BSTree.h file. In
particular, this class inherits from the BinaryTree class. Thus, the parent functions
such as
PreOrderTraverse
BinaryTreeNodeYou need to complete a BSTree Binary Search Tree class in the BSTree.h file. In
particular, this class inherits from the BinaryTree class. Thus, the parent functions
such as
PreOrderTraverseBinaryTreeNode
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started