switch(flag)
...{
case 0:
return 0;
case 1:
...{
printf("Please input the value you want to input:");
scanf("%d",&value);
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
newNode->key=value;
newNode->parent=NULL;
newNode->left=NULL;
newNode->right=NULL;
Root=Insert(Root,newNode);
break;
}
case 2:
...{
printf("Please input the value you want to delete:");
scanf("%d",&value);
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
newNode=Search(Root,value);
if(newNode!=NULL)
Root=Delete(Root,newNode);
else
printf("%d does'n exist in this tree! ",value);
break;
}
case 3:
...{
printf("Please input the value you want to input:");
scanf("%d",&value);
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
newNode=Search(Root,value);
if(newNode!=NULL)
printf("%d exist in this tree! ",newNode->key);
else
printf("%d does'n exist in this tree! ",value);
break;
}
case 4:
...{
if(Root!=NULL)
...{
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
newNode=Minimum(Root);
printf("The minimum value of this tree is %d! ",newNode->key);
}
else
printf("This tree is empty! ");
break;
}
case 5:
...{
if(Root!=NULL)
...{
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
newNode=Maximum(Root);
printf("The Maximum value of this tree is %d! ",newNode->key);
}
else
printf("This tree is empty! ");
break;
}
case 6:
...{
printf("Please input the value:");
scanf("%d",&value);
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
newNode=Search(Root,value);
if(newNode!=NULL)
...{
newNode=Successor(newNode);
if(newNode!=NULL)
printf("%d's successor is %d! ",value,newNode->key);
else
printf("%d has't successor int this tree! ",value);
}
else
printf("%d does'n exist in this tree! ",value);
break;
}
case 7:
...{
printf("Please input the value:");
scanf("%d",&value);
struct Node *newNode=(struct Node*)malloc(sizeof(struct Node));
newNode=Search(Root,value);
if(newNode!=NULL)
...{
newNode=Predecessor(newNode);
if(newNode!=NULL)
printf("%d's Predecessor is %d! ",value,newNode->key);
else
printf("%d has't predecessor int this tree! ",value);
}
else
printf("%d does'n exist in this tree! ",value);
break;
}
default:
break;
}