. Show the result of inserting 3,1,4,6,9,2,5,7 into an initial empty binary search tree.
时间: 2023-10-09 13:15:20 浏览: 201
Binary Search Tree
Here are the steps to insert the given values into an empty binary search tree:
1. Insert 3 as the root node.
```
3
```
2. Insert 1 as the left child of 3.
```
3
/
1
```
3. Insert 4 as the right child of 3.
```
3
/ \
1 4
```
4. Insert 6 as the right child of 4.
```
3
/ \
1 4
\
6
```
5. Insert 9 as the right child of 6.
```
3
/ \
1 4
\
6
\
9
```
6. Insert 2 as the left child of 1.
```
3
/ \
1 4
/ \
2 6
\
9
```
7. Insert 5 as the right child of 4.
```
3
/ \
1 4
/ / \
2 5 6
\
9
```
8. Insert 7 as the right child of 6.
```
3
/ \
1 4
/ / \
2 5 6
\
9
/
7
```
阅读全文