void printBoundaryLeft(TreeNode* root){ if(root){ if(root->left){ //to ensure top down order, print the node // before calling itself for left subtree cout<<root->data<<" "; printBoundaryLeft(root->left); } else if(root->right){ cout<<root->data<<" "; printBoundaryLeft(root->right); } } }
void printBoundaryLeft(struct BSTNode* root) { if (root) { if (root->left) { printf("%d ", root->data); printBoundaryLeft(root->left); } else if (root->right) { printf("%d ", root->data); printBoundaryLeft(root->right); } } }
void printBoundary(struct BSTNode* root) { if (root) { printf("%d ", root->data); printBoundaryLeft(root->left); printLeaves(root->left); printLeaves(root->right); printBoundaryRight(root->right); } }
void printBoundary(TreeNode* root){ if(root){ cout<<root->data<<" "; //Print all left boundary in top down manner. printBoundaryLeft(root->left); //Print all leaf node printLeaves(root->left); printLeaves(root->right); //Print all right boundary nodes in bottom up manner. printBoundaryRight(root->right); } }