Question: In the assignment you will implement a BinarySearch Tree class. You should design this class so that it is efficient. You are allowed to

In the assignment you will implement a BinarySearch Tree class. You should design this class so that it is efficient. You are allowed to use helper classes (e.g. Node). Note efficient does not require you implement a balanced binary tree; see the extra credit for that. For the specifications below, you should implement a standard binary tree. Your class should use Java generics. Generics allow for arbitrary types of keys and values in your BST. Use T and V to indicate the generic types of the keys and values, respectively. These should be stored in the search tree Node class. The generic type T for the keys should implement the Comparable interface. The value V can be any type of data, which is associated with the key. This approach enhances encapsulation, because the Node class is hidden in the BST class, and each method only returns the stored value, not the object used to store the value. Create a class named BinarySearchTree with the following methods: void insert(T key, V value) - inserts a node containing key with associated value in the BST V search (T key) - searches for a node with a specific key in the BST. In the case where a tree contains duplicates, search returns the first node encountered. void delete (T key) - deletes a node containing key from the BST if it exists returns a list of values in inorder traversal of the BST implemented using List inorderRec() recursion V kthSmallest (int k) - find the kth smallest element in the BST Activate Win
Step by Step Solution
There are 3 Steps involved in it
BSTTry It Program to implement search in BST Python3 function to search a given key in a given BST c... View full answer
Get step-by-step solutions from verified subject matter experts
