I have written a code for finding diameter of Binary Tree. Need suggestions for the following:
public class NodeWrap{
int height = 0;
int maxLength = 0;
public NodeWrap(int h, int m){
height = s;
maxLength = m;
}
}
public NodeWrap getDiameter(BinaryNode root){
if(root == null){
return new NodeWrap(0, 0);
}
NodeWrap left = getDiameter(root.left);
NodeWrap right = getDiameter(root.right);
int height = Math.max(left.height + right.height) + 1;
int maxLength = Math.max(left.maxLength, right.maxLength);
if(left.height != 0 && right.height != 0){
maxLength = Math.max(left.height + right.height + 1, maxLength);
}
return new NodeWrap(singleLength, maxLength);
}