Actually I\'m wodering could you help me to solve ?4??5??6??7?according to the binary tree node class which is given already?
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) public int size()
{
return(size(root));
}
private int size(Node node)
{
if (node == null) return(0);
else
{
return(size(node.left) +1 + size(node.right));
}
}
2)
public int diametre(Node node, int d)
{
if(node==null)
return 0;
lh=diametre(node.left, d);
rh=diametre(node.right, d);
if(lh+rh+1>d)
d=lh+rh+1;
return findMax(lh, rh)+1;
}
3)
public void levelorderqueue(Node root)
{
Queue<Node> q = new LinkedList<Node>(0);
if (root == null)
return;
q.add(root);
while (!q.isempty())
{
Node n = (Node) q.remove(0);
system.out.print(\" \"+n.data);
if (n.left !=null)
q.add(n.left);
if (n.right != null)
q.add(n.right);
}
}