Please i need help on following program using C Language Add
Please i need help on following program using C++ Language.
Add these three functions to the class binaryTreeType (provided) at below.
Write the definition of the function, nodeCount, that returns the number of nodes in the binary tree.
Write the definition of the function, leavesCount, that takes as a parameter a pointer to the root node of a binary tree and returns the number of leaves in a binary tree.
Write a function, swapSubtrees, that swaps all of the left and right subtrees of a binary tree. Print the original tree and the resulting tree using a pre-order traversal.
Write a program to test your new functions. Use the data provided to build your binary search tree (-999 is the sentinel):
Data: 65 55 22 44 61 19 90 10 78 52 -999
HERE IS BinaryTreeType.h
Solution
#ifndef H_binaryTree
 #define H_binaryTree
 
 #include <iostream>
using namespace std;
//Definition of the Node
 template <class elemType>
 struct nodeType
 ;
   
 //Definition of the category
 template <class elemType>
 class binaryTreeType
 to work out whether or not the binary tree is empty.
 //Postcondition: Returns true if the binary tree is empty;
 // otherwise, returns false.
void inorderTraversal() const;
 //Function associated do} an inorder traversal of the binary tree.
 //Postcondition: Nodes square measure written in inorder sequence.
void preorderTraversal() const;
 //Function to try to to a preorder traversal of the binary tree.
 //Postcondition: Nodes square measure written in preorder sequence.
void postorderTraversal() const;
 //Function to try to to a postorder traversal of the binary tree.
 //Postcondition: Nodes square measure written in postorder sequence.
int treeHeight() const;
 //Function to see the peak of a binary tree.
 //Postcondition: Returns the peak of the binary tree.
void destroyTree();
 //Function to destroy the binary tree.
 //Postcondition: Memory area occupied by every node
 // is deallocated.
 // root = NULL;
virtual bool search(const elemType& searchItem) const = 0;
 //Function to see if searchItem is within the binary
 //tree.
 //Postcondition: Returns true if searchItem is found in
 // the binary tree; otherwise, returns
 // false.
virtual void insert(const elemType& insertItem) = 0;
 //Function to insert insertItem within the binary tree.
 //Postcondition: If there\'s no node within the binary tree
 // that has identical information as insertItem, a
 // node with the information insertItem is made
 // and inserted within the binary search tree.
virtual void deleteNode(const elemType& deleteItem) = 0;
 //Function to delete deleteItem from the binary tree
 //Postcondition: If a node with identical information as
 // deleteItem is found, it\'s deleted from
 // the binary tree.
 // If the binary tree is empty or
 // deleteItem isn\'t within the binary tree,
 // Associate in Nursing applicable message is written.
 binaryTreeType(const binaryTreeType<elemType>& otherTree);
 //Copy creator
binaryTreeType();   
 //Default creator
~binaryTreeType();   
 //Destructor
protected:
 nodeType<elemType> *root;
private:
 void copyTree(nodeType<elemType>* &copiedTreeRoot,
 nodeType<elemType>* otherTreeRoot);
 //Makes a replica of the binary tree to that
 //otherTreeRoot points.
 //Postcondition: The pointer copiedTreeRoot points to
 // the basis of the derived binary tree.
void destroy(nodeType<elemType>* &p);
 //Function to destroy the binary tree to that p points.
 //Postcondition: Memory area occupied by every node, in
 // the binary tree to that p points, is
 // deallocated.
 // p = NULL;
void inorder(nodeType<elemType> *p) const;
 //Function associated do} an inorder traversal of the binary
 //tree to that p points.
 //Postcondition: Nodes of the binary tree, to which p
 // points, square measure written in inorder sequence.
void preorder(nodeType<elemType> *p) const;
 //Function to try to to a preorder traversal of the binary
 //tree to that p points.
 //Postcondition: Nodes of the binary tree, to which p
 // points, square measure written in preorder
 // sequence.
void postorder(nodeType<elemType> *p) const;
 //Function to try to to a postorder traversal of the binary
 //tree to that p points.
 //Postcondition: Nodes of the binary tree, to which p
 // points, square measure written in postorder
 // sequence.
int height(nodeType<elemType> *p) const;
 //Function to see the peak of the binary tree
 //to that p points.
 //Postcondition: Height of the binary tree to that
 // p points is came back.
int max(int x, int y) const;
 //Function to see the larger of x and y.
 //Postcondition: Returns the larger of x and y.
 };
//Definition of member functions
template <class elemType>
 binaryTreeType<elemType>::binaryTreeType()
 template <class elemType>
 bool binaryTreeType<elemType>::isEmpty() const
 come (root == NULL);
 }
template <class elemType>
 void binaryTreeType<elemType>::inorderTraversal() const
 template <class elemType>
 void binaryTreeType<elemType>::preorderTraversal() const
 template <class elemType>
 void binaryTreeType<elemType>::postorderTraversal() const
 template <class elemType>
 int binaryTreeType<elemType>::treeHeight() const
 come height(root);
 }
template <class elemType>
 int binaryTreeType<elemType>::treeNodeCount() const
 come nodeCount(root);
 }
template <class elemType>
 int binaryTreeType<elemType>::treeLeavesCount() const
 come leavesCount(root);
 }
template <class elemType>
 void binaryTreeType<elemType>::copyTree
 (nodeType<elemType>* &copiedTreeRoot,
 nodeType<elemType>* otherTreeRoot)
} //end copyTree
template <class elemType>
 void binaryTreeType<elemType>::inorder
 (nodeType<elemType> *p) const




