PROGRAMMING:Delete Nodes in a Binary Search Tree
Given a binary search tree with no same keys, you should output the level-order traversal sequence of this tree after some nodes are deleted.
When trying to remove a node from the tree, we follow the rules listed below:
* If the node to be deleted is a leaf node, remove it directly;
* If the node has left subtree, set its key to be the maximum key in its left subtree and remove the node in its left subtree with maximum key;
* If the node doesn’t have left subtree but has right subtree, set its key to be the minimum key in its right subtree and remove the node in its right subtree with minimum key.
#### Input Specification:
Each input file contains one test case. The first line of each test contains a number $$N$$ ($$1#### Output Specification:
Output the level-order traversal sequence of the tree. Numbers in the sequences must be separated by a space, and no extra space is allowed at the end of line.
#### Sample Input:
```in
seven
4 2 1 3 6 5 7
two
3 6
```
#### Sample Output:
```out
4 2 5 1 7
```
answer:If there is no answer, please comment
When trying to remove a node from the tree, we follow the rules listed below:
* If the node to be deleted is a leaf node, remove it directly;
* If the node has left subtree, set its key to be the maximum key in its left subtree and remove the node in its left subtree with maximum key;
* If the node doesn’t have left subtree but has right subtree, set its key to be the minimum key in its right subtree and remove the node in its right subtree with minimum key.
#### Input Specification:
Each input file contains one test case. The first line of each test contains a number $$N$$ ($$1
Output the level-order traversal sequence of the tree. Numbers in the sequences must be separated by a space, and no extra space is allowed at the end of line.
#### Sample Input:
```in
seven
4 2 1 3 6 5 7
two
3 6
```
#### Sample Output:
```out
4 2 5 1 7
```
answer:If there is no answer, please comment