Question: java data structure Implement a Binary Search Tree (BST) that stores student information. Each tree node stores: student ID as the key, and student name
java data structure
Implement a Binary Search Tree (BST) that stores student information. Each tree node stores: student ID as the key, and student name as the value. Your BST class should have root and size as instance variables. It should also have the following methods:
printID (): this method takes a name as an argument and returns the student ID (the key). Note that this is not a typical BST operation. You can add more parameters to the method header if needed.
findKthsmall(int k): this method finds and returns the kth smallest key. If the tree has less than k elements, the method returns -1. You can add instance variables to the BST class if needed. You can also pass whatever parameters you need for your method to work. [Hint: remember that inorder traversal gives us the keys in an ascending order, hence, if I want the 3rd smallest element, then the method should return the third number of the inorder traversal list].
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
