PR 4 B-6
PR 4 B-6
return node;
struct bstnode }
return root;
} }
{ {
inorder(root->right); }
{
struct bstnode* insert(struct bstnode* node, int key)
if (root == NULL)
{
return root;
if (node == NULL) return newNode(key);
if (key < root->data)
if (key < node->data)
root->left = deleteNode(root->left, key);
node->left = insert(node->left, key);
else if (key > root->data) return;
else {
mirror(node->left);
} }
} return NULL;
{ root2->left=copy(root->left);
return 0;
void mirror(struct bstnode* node)
}
{
else
if (node == NULL)
{
cout<<"\n*************************************
int depth1=Maxdepth(root->left);
*******";
int depth2=Maxdepth(root->right);
cout<<"\nEnter your choice: ";
if(depth1>depth2)
cin>>ch;
return (depth1+1);
switch(ch)
else
{
return (depth2+1);
case 1:
break;
cout<<"\n****************MENU****************
*********"; case 3:
cout<<endl<<"\t\t2.DELETE"; cin>>d;
cout<<endl<<"\t\t4.TRAVERSAL"; if(root1!=NULL)
cout<<endl<<"\t\t8.EXIT";
break;
case 4:
inorder(root);
break;
case 5:
depth=Maxdepth(root);
break;
case 6:
root2=copy(root);
inorder(root2);
break;
case 7:
mirror(root);
inorder(root);
mirror(root);
break;
case 8:
return 0;
default:
cout<<"\nWrong Option";
return 0;