Skip to main content

Section 10.6 Binary Search Tree Exercise

Subsection 10.6.1 Goals

The purpose of this assignment is to learn to
  1. Access remote data through BRIDGES.
  2. Manipulate a binary search tree using the earthquake magnitude (or some other attribute) as a search key
  3. Traverse BST using different methods.

Subsection 10.6.2 Programming Tasks

Starting file: BST_eq.java 1 
Build a binary search tree where each node represents an earthquake record
Steps:
  1. Open your base code.
  2. Plug in your credentials.
  3. Complete the insert_R() function to recursively insert objects into the binary search tree. You should insert objects based on the magnitude of the earthquake.
  4. Perform a traversal on the completed BST.
  5. Perform a binary search to find the biggest earthquake based on magnitude and color it red.

Subsection 10.6.3 Building The BST

  1. Your BSTElement will use EarthquakeUSGS as the generic parameter, using Double as the key type. The key is will be the magnitude of the earthquake.
  2. Write an insert() method, creating and inserting earthquake records into a binary search tree, using the magnitude of the quake as a search key. Color the nodes less than 3.0 magnitude orange and the nodes greater than or equal to 3.0 magnitude green (10 points)
  3. Color the root node in a unique color. (done for you)
  4. Perform a traversal of the tree and color leaf nodes black. (10 points)
  5. Traverse the tree to find the largest quake and style it RED. (5 points)
  6. Once completed, submit your code and link to the visualization. (2 points)
You have attempted of activities on this page.
uncc.instructure.com/courses/16965/files/21470633?wrap=1