int getTreeHeight(Node N)
{
if (n==null) return 0;
return 1+ Math.max( getTreeHeight(N.getLeft(), getTreeHeight(N.getRight() );
}
void preorderTraversal( Node root )
{
if (root == null ) return;
root.printValue();
preorderTraversal(root.getLeft());
preorderTraversal(root.getRight());
}
void preorderTraversal( Node root )
{
Stack stack = new Stack();
stack.push(root);
while(!stack.empty())
{
Node curr = stack.pop();
curr.printValue();
Node n = curr.getRight();
if(n != null) stack.push(n);
Node n = curr.getLeft();
if(n != null) stack.push(n);
}
}
글 잘 봤습니다, 많은 도움이 되었습니다.