11void CreateTree(
node *curr,
node *n,
int x,
char pos) {
14 cout <<
"\nLeft or Right of " << n->val <<
" : ";
17 CreateTree(n, n->left, x, ch);
19 CreateTree(n, n->right, x, ch);
27 }
else if (pos ==
'r') {
38 while (!queue.empty()) {
40 cout << n->val <<
" ";
44 queue.push_back(n->left);
46 queue.push_back(n->right);
52 cout << n->val <<
" ";
61 cout << n->val <<
" ";
70 cout << n->val <<
" ";
78 cout <<
"\nEnter the value of root node :";
84 cout <<
"\n1. Insert";
85 cout <<
"\n2. Breadth First";
86 cout <<
"\n3. Preorder Depth First";
87 cout <<
"\n4. Inorder Depth First";
88 cout <<
"\n5. Postorder Depth First";
90 cout <<
"\nEnter Your Choice : ";
96 cout <<
"\nEnter the value to be Inserted : ";
98 cout <<
"\nLeft or Right of Root : ";
101 CreateTree(root, root->left, x, pos);
103 CreateTree(root, root->right, x, pos);
struct node { int data; int height; struct node *left; struct node *right;} node
for std::queue