Question: IN JAVA CODE: Write a BSTDictionary class that uses a binary search tree to implement a dictionary. Dont let the two generic type parameters throw

IN JAVA CODE:

Write a BSTDictionary, V> class that uses a binary search tree to implement a dictionary. Dont let the two generic type parameters throw you off! They just mean that when you create a new instance of BSTDictionary, you will need to specify two data types: one for the keys, and one for the values. The K extends Comparable means that whatever type you specify for the keys must be something that implements the Comparable interface (which makes sense, since the keys must be comparable to place them into a binary search tree). Your BSTDictionary class must support the following operations: a. add(K key, V value) Inserts the specified key-value pair into the dictionary. If the key already exists, this method should replace that keys value with the new one. b. getValue(K key) Returns the value associated with the specified key. c. contains(K key) Returns whether the specified key exists in the dictionary. d. iterator() Returns an iterator over the elements in the dictionary.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!