Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Fall 2022

Computer Science II

Homework BST Earthquake

Include the following comments at the top of each of your .java files:

// author :

// assignment :

// description:

You are not allowed to use in your code not done by yourself, no method/functions that were not coded by you, even the ones that are imported from Java.

If your code does not compile or run, you will also end with a 0 on this HW.

http://bridges-cs.herokuapp.com

Download the code below, run in your computer, this is a way to see if your user/connection to bridges is working well.

In this homework we will use the Earthquake data that Bridges has, so read it and get familiar with it:

http://bridgesuncc.github.io/doc/java-                                                                                             api/current/html/classbridges_1_1data__src__dependent_1_1_earthquake_u_s_g_s.html

In this homework we will Implement a BST by following the steps described below. Do your work on a           directory named HW-BST. Once your code has been compiled and tested, remove all compiled “ .class” files, create a package named HW-BST.zip, and upload it on Canvas.

1)   (1 pt.) You will use (change) the class you had in the previous HW that was called Point to ListPoint, of         course you have to change all the methods inside as needed to make the class compile and work. This class has the following properties:

a)    Private fields next, pointing to the next point in the list.

b)   Private field country, defined as a String.

c)    Private field magnitude, defined as Double.

d)   Private field month, defined as a String.

e)   Private field year, defined as a int.

f)    Public constructor that takes country, magnitude, moth and year as arguments.

g)   Public methods/functions getters and setters for all classes attributes.

2)   (2 pt.) You will use create a class called TreePoint (file TreePoint.java) and it will have the following properties :

a)    Private fields left and right, pointing to the left and right TreePoint in the list.

b)   Private field country, defined as a String.

c)    Private field magnitude, defined as Double.

d)   Private field month, defined as a String.

e)   Private field year, defined as a int.

f)    Public constructor that takes country, magnitude, moth and year as arguments.

g)   Public methods/functions getters and setters for all classes attributes.

3)   (7 pt.) In the class BST, file given (named MinimalLinkedList.java). Do the following:

a)   (3 pt.) Private static function/method BuildTree(), which returns the BST. The method/function is static and receives a MinimalLinkedList as parameter and an int that will define the root of the BST. In case     the list is empty it should return null. The BuildTree() method should call another method called             InsertBST() (detailed below) that will really add the TreePoint in the correct place into to the BST. It       should evaluate the magnitude of the quake and according to that it will put the TreePoint to the left    or to the right. The majorities of earthquakes are small, the MinimalLinkedList class only considers         earthquakes that are bigger than 2 in magnitude. To avoid that your BST is too heavy on any side,           assume that you the second parameter you get is a number like 3 that will define the root. In your         implementation assume at the beginning that you have a TreePoint with a 3, and while you build your  tree you evaluate the information given to find a real quake value that will be the real root of the BST   tree. The method BuildTree

b)   (2 pt.) Private non static function/method InsertBST(), used to add the TreePoint that receives as an argument/parameter to the right spot into the BST tree.

c)   (2 pt.) Public function/method UpdateRoot() used to change the fake root created in the BuildTree() method/function with the closest real value that was gathered. Assume that the value we have hard  coded in the moment (3) is not fixes, we can change that to a user parameter. If you update the root after the tree is created you need to delete the TreePoint that was used from its original place on the BST. If you are doing this dynamically, while you are building the BST you don’t need to worry about  that.