Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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* obj); // sets left child value

void setright(Binary_node* obj); // sets right child value

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*); // deletes the tree

void setData(Type x);

};

template <typename Type>

class Binary_Search_Tree

{

private:

Binary_node* root_node;

public:

Binary_Search_Tree(); // constructor

Binary_node* root() const; // returns the root 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* search(Type obj); // searches elements

};

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

=+(5.42) E[n \N2] = a, Var[n 'N.] - B - x2 +H-P n

Answered: 1 week ago