void printBoundaryRight(TreeNode* root){ if(root){ if(root->right){ cout<<root->data<<" "; printBoundaryRight(root->right); } else if(root->left){ cout<<root->data<<" "; printBoundaryRight(root->left); } } }
void printBoundaryRight(struct BSTNode* root) { if (root) { if (root->right) { printBoundaryRight(root->right); printf("%d ", root->data); } else if(root->left) { printBoundaryRight(root->left); printf("%d ", root->data); } } }
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); } }