Question: Overview: In this lab, you will implement your own binary search tree class and associated methods (it does not need to be balanced). The methods

Overview:

In this lab, you will implement your own binary search tree class and associated methods (it does not need to be balanced). The methods you need to implement are: put put a new key-value pair into the data structure

get return the value for a given key (or null if key not present)

floor return the largest key in the data structure that is <= to the given key (or null)

ceiling return the smallest key in the data structure that is >= to the given key (or null)

show a method that prints all key-value pairs stored, in order

You should also implement a simple user interface to test the code. Here is a sample interaction:

java MyBST

Welcome to my MyBST! Here are the commands you can use: (p)ut key value (g)et key (f)loor key

(c)eiling key (s)how e(x)it

> p 5 cat

> p 10 dog

> g 5

cat

> g 8

not found > f 8 5 > c 10 10 > c 11 not found > s 5 cat

10 dog > x

Bye!

You may assume that the keys are ints and the values are Strings.

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!