Question
Please implement the function of finding the successor of a given node using the Binary Search Tree Classes given below: template < typename Type> class
Please implement the function of finding the successor of a given node using the Binary Search Tree Classes given below:
template <typename Type>
class Binary_node
{
protected:
Type element; // stores the key/data
Binary_node* left_tree; // address to the left subtree
Binary_node* right_tree; // address to the right subtree
public:
Binary_node(Type const&); // constructor for initialisation
Type retrieve() const; // returns the key/data in the node
Binary_node* left() const; // returns the left child node
Binary_node* right() const; // returns the right child node
void setleft(Binary_node
void setright(Binary_node
bool empty() const; // checks if the tree is empty;
bool is_leaf() const; // checks if the node is a leaf node
int size() const; // returns the size/number of nodes in the tree
int height() const; // returns the height of tree
void clear(Binary_node
void setData(Type x);
};
template <typename Type>
class Binary_Search_Tree
{
private:
Binary_node
public:
Binary_Search_Tree(); // constructor
Binary_node
bool empty() const; // check whether the tree is empty
int size() const; // calculates the size of tree
int height() const; // calculates the height of tree
void insert(Type obj); // inserts elements wrt bst logic
Binary_node
};
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