, , .
printBorder (, , ) . : , .
function printBorder(
Node node, bool printLeft, bool printRight, int height, const int MAX_HEIGHT) {
if (printLeft || printRight ||
(node.left == null && node.right == null && height == MAX_HEIGHT)) {
print node;
}
if (node.left) printBorder(node.left, printLeft, printRight && node.right==null)
if (node.right) printBorder(node.right, printLeft && node.left == null, printRight)
}
MAX_HEIGHT maxdepth (root, 0);
int maxdepth(Node node, int height) {
if (node == null) return height;
return max(maxdepth(node.left, height+1), maxdepth(node.right, height+1))
}