Section 8.12 Search Tree Operations
Before we look at the implementation, let’s discuss the operations that will be provided by the
BinarySearchTree
. You should notice that this interface is very similar to the C++ Hash Table in Section 6.5. While the operations provided by BinarySearchTree
are the same as the Hash Table, we will see that how items are stored and accessed is very different.BinarySearchTree()
Create a new, empty tree.put(key,val)
Add a new key-value pair to the tree. If the key is already in the tree then replace the old value with the new value.get(key)
Given a key, return the value stored in the tree orNULL
otherwise.del(key)
Delete the key-value pair from the tree.length()
Return the number of key-value pairs stored in the tree.
You have attempted of activities on this page.