Menu

[Solved]Let Consider Following Template Binary Trees Template Class Binarytree Private Declare Str Q37118063

Let consider the following template of binary trees

template <typename T> class BinaryTree{ private:

// Declare a structure for the list struct TreeNode
{

T value;
struct TreeNode *left; struct TreeNode *right;

};
TreeNode *root; // tree root pointer // A function to create anode
TreeNode * createNode(T key){

TreeNode *node = new TreeNode; node->value = key;
node->left = NULL;
node->right = NULL;

return node; }

public:
BinaryTree (void) // Constructor

{ root = NULL; }

1

BinaryTree (T);
~ BinaryTree (void); // Destructor T& top();
T& pop_front();
bool empty();
void insertNode(T);
void deleteNode(T, bool);
void preOrderTraversal();
void inOrderTraversal();
void postOrderTraversal();
int countLesserThan(T);
int countGreaterThan(T);
int length();
int height();
void clear();
void mirror();
bool isIdenticalTo(BinaryTree); bool isIsomorphicWith(BinaryTree);int countLeafNodes();
int countSemiLeafNodes();

};
Suppose that this class permits the manipulation of binary searchtrees. Write an algorithm

(Pseudo-code please, no sentences!!) and a C++ program for eachof the following methods for this BinaryTree class:

1. BinaryTree(T info): the constructor to create a binary treewhich first node contains the value info and the next pointer isnull.
Hint: use the function TreeNode * createNode(T key);

Expert Answer


Answer to Let consider the following template of binary trees template class BinaryTree{ private: // Declare a structure for the l… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *