Question 1
(1) (2) (3) (4) A 10 cat 15 / \ / / \ / \ B C 5 bat rat 5 22 / / \ \ -3 ant 20 30
Question 2
The BST that results from inserting the values 5 3 7 6 2 1 4 in that order is:
5 / \ 3 7 / \ / 2 4 6 / 1
The BST that results from inserting the values 1 2 3 4 5 6 7 in that order is:
1 \ 2 \ 3 \ 4 \ 5 \ 6 \ 7
The BST that results from inserting the values 4 3 5 2 6 1 7 in that order is:
4 / \ 3 5 / \ 2 6 / \ 1 7
private K smallest(BSTnode<K> n) // precondition: n is not null // postcondition: return the smallest value in the subtree rooted at n { if (n.getLeft() == null) { return n.getKey(); } else { return smallest(n.getLeft()); } }