I\'m wondering could you help me to solve?fill?each question?method??and you don\'t have to write the whole code with main function?just make these 7 methods valid combined with the given Class BTNode and the given information of each question??For?3??deque class should be considered?For other questions “this”node is important?you cannot omit it?Anyway?thank you so much?
7. (40 pts) Answer the following questions on the binary tree node class given below. template class BTNode public: // members BTNode* parent; BTNode left BTNode right; E data; // given methods BTNode () { parent = left = right = NULL; } bool has Left() { return left != NULL; } bool hasRight) return right- NULL; bool isLeaf) return left NULL && rightNULL;) bool isRoot () return parentNULL; BTNode* connectLeft(BTNode* n) { left = n; n->parent = this; return n;} BTNode connectRight (BTNode* n) right n; n->parent this; return n;) int getletfBranchheight() { return hasleft() ? left->getHeight() + 1 : 0; } int getRightBranchHeight() { return hasRight() ? right->getHeight() + 1 : 0; } int getHeight) f return max(getLeftBranchHeight (O, getRightBranchHeightO); // methods to be filled int getsize); int getDiameterO; void leve10rder(vector& V); BTNode findMin() bool isNormalNode() bool isNormalTree) BTNode normalizeTree); d; (1) (5 pts) Complete the following method which returns the size of subtree rooted at this node. int getSize) f (2) (7 pts) Diameter of a tree is the longest path in the tree. Complete the following method which returns the diameter of subtree rooted at this node. int getDiamter)
1)
int size (Node node)
{
if (node == null)
return 0;
else
return (size(node.left) + 1 + (size(node.right));
}
2)
public static int getDiameter(binary TreeNode root)
{
if Iroot == null)
return 0;
int rootDiameter = getHeight(root.getLeft()) + getHeight( root.getRight()) + 1;
int leftDiameter = getDiameter (root.getLeft( ) );
int rightDiameter = getDiameter(root.getRight( ) );
return Math.max ( rootDiameter, Math.max( leftDiameter, rightDiameter ) );
}
public static int getHeight(BinaryTreeNode root) {
if ( root == null)
return 0;
return Math.max( getHeight(root.getLeft( ) ), getHeight ( root.getRight( ) ) ) +1;
}
6)
class BinaryTree
{
Node root;
boolean is FullTree( Node node)
{
if( node == null)
return true;
if( node.left == null && node.right ==null )
return true;
if ( ( node.left!= null) && (node.right!=null) )
return (isfullTree(node.left) && isFullTree(node.right) );
retuen false;
}
3)
void printLevelOrder( struct node* root)
{
int h = height(root);
int i;
for ( i=1; i<=h; i++)
printGivenLevel( root, i);
}