29void Insert(
node *n,
int x) {
31 if (n->left == NULL) {
41 if (n->right == NULL) {
53int findMaxInLeftST(
node *n) {
54 while (n->right != NULL) {
60void Remove(
node *p,
node *n,
int x) {
62 if (n->right == NULL && n->left == NULL) {
68 }
else if (n->right == NULL) {
74 }
else if (n->left == NULL) {
81 int y = findMaxInLeftST(n->left);
83 Remove(n, n->right, y);
85 }
else if (x < n->val) {
86 Remove(n, n->left, x);
88 Remove(n, n->right, x);
94 std::cout << n->val <<
" ";
103 std::cout << n->val <<
" ";
112 std::cout << n->val <<
" ";
121 std::cout << n->val <<
" ";
131 std::cout <<
"\nEnter the value of root node :";
137 std::cout <<
"\n1. Insert"
139 <<
"\n3. Breadth First"
140 <<
"\n4. Preorder Depth First"
141 <<
"\n5. Inorder Depth First"
142 <<
"\n6. Postorder Depth First";
144 std::cout <<
"\nEnter Your Choice : ";
149 std::cout <<
"\nEnter the value to be Inserted : ";
154 std::cout <<
"\nEnter the value to be Deleted : ";
156 Remove(root, root, x);
struct node { int data; int height; struct node *left; struct node *right;} node
for std::queue