previous | start | next

The put(Key key, Value val) Method

Using a binary search tree provides a nice improvement for the put method.

For the array implementation, we have to move all larger keys, but not for the binary search tree.

The put method again searches efficiently, but it doesn't have to move any other keys.

So the code is just a small variation on the recursive code for the get method:

Again, the recursive code serves as an inductive proof of correctness.



previous | start | next