Question: Complete the implementation of all functions in BinarySearchTree.h . main.cpp code: #include #include #include #include BinarySearchTree.h using namespace std; / / Do not modify
Complete the implementation of all functions in BinarySearchTree.h
main.cpp code:
#include
#include
#include
#include "BinarySearchTree.h
using namespace std;
Do not modify the contents of this file
int main
BinarySearchTree tree;
tree.insert;
tree.insert;
tree.insert;
tree.insert;
tree.insert;
tree.draw;
BinarySearchTree backup tree;
tree.insert;
tree.draw;
backup.draw;
backup.removebackupsearch;
backup.draw;
backup.removebackupsearch;
backup.draw;
return ;
BinarySearchTree.h code:
#ifndef BSTH
#define BSTH
#include
struct Node
int data;
Node left;
Node right;
Nodeint x
data x;
left nullptr;
right nullptr;
;
class BinarySearchTree
Node root;
public:
BinarySearchTree
BinarySearchTreeconst BinarySearchTree& other
void insertint x
void traverse
Node searchint x
Node min
Node max
Node successorNode start
Node findParentNode start
void removeNode node
A function to display the tree graphically
void displayTreeNode r int level, int direction
Don't worry about this function, just use it
if r NULL
displayTreerright, level;
for int i ; i level; i
std::cout ;
if level
if direction
std::cout ;
else
std::cout ;
std::cout rdata;
std::cout std::endl;
level;
displayTreerleft, level, ;
Call the function to display the tree and leave some space afterwards
void draw
displayTreeroot;
std::cout std::endl std::endl;
;
#endif
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
