Question: Objectives: You are given two classes for implementing a simple binary tree of capable of storing number, count the number of leaves and computes the

Objectives:You are given two classes for implementing a simple binary tree of capable of storing number, count the number of leaves and computes the height of a binary tree.

You can add on additional parameters or functions as you wish but the program must apply the chapter objectives.

Objectives:You are given two classes for implementing a simple binary tree of

class BTreeNode public: BTreeNode (double x, BTreeNode *leftp - NULL, BTreeNode *rightp = NULL) value = x} left = leftp; right = rightp; } private: double value; BTreeNode "left, "right; friend class BST; // BST has friend status // Binary tree class itself class BST public: int height() { return height (tree); } // return the tree height void insert (double x) ; // insert numbers into the binary tree void inorder(vector & v) { inorder(v, tree); } // appends all nodes in subtree int leafCounter () { return leafCounter (tree); } // count the number of leaves BST() { tree = NULL; } private: void inorder(vector&tlist, BTreeNode *t); // storing nodes in subtree int leafCounter (BTreeNode *t); // count the number of leaves static int height (BTreeNode *t); // calculate the height of the tree BTreeNode *tree; Sample output: This program allows you to insert some numbers in binary search tree. It prints out the numbers in the tree in inorder. It computes and prints the number of leaves in the tree. and the height of the tree. Enter 10 numbers: 8 20 6 4 23 30 29 33 7 45 The items in the tree in inorder are: 4 6 7 8 20 23 29 30 33 45 The height of the tree is 6 The number of leaves is 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!