Question: The current implementation uses a linked list that works poorly under common loads. Implement a binary search tree and the methods to support it .
The current implementation uses a linked list that works poorly under common loads. Implement a binary
search tree and the methods to support it
The skeleton code has an abstract LocationContainer class. This class has methods to build a data
structure, find values in it and find the next or previous location. It also has two important parts of a
binary tree implemented: root and nil. Use these values instead of reimplementing your own. There is one
class already implemented:
L Implements a linked list data structure
For this assignment, you will implement the methods in the remaining class: BSTjava as a binary search
tree. For sources for this assignment, you should use the lecture slides and the book chapter I would
recommend sticking closely to the pseudocode, and using the nil construct that the book suggests. nil is
implemented in LocationContainer for you already.
This skeleton code has a lot of moving parts. There is an abstract LocationContainer class, which L and
BST both inherit from. There is a supporting node class called DiskLocation.java that holds the location
and all necessary node information. It also has a comparator method, isGrEATERTHAN, that you should
use to compare DiskLocations to each other. You should not modify any file besides BSTjava. You can
add as many private supporting methods as you need.
The height of a tree is defined as the number of steps it takes to get from the root to the deepest child. This
means a tree with a single node has a height of A balanced tree with nodes has a height of Check
out the SIZE method in LocationContainer for an idea how to measure the height. Think of the height of
the node as the height of its larger subtree.
The FIND method should return the DiskLocation in your BST that has the same tracksector values as the
input parameter.
The NEXT and PREV methods should return nil if they are called with the largestsmallest value in the tree,
respectively.
TODO: document class
public class BST extends LocationContainer
@Override
public DiskLocation findDiskLocation d
TODO: implement method
return null;
@Override
public DiskLocation nextDiskLocation d
TODO: implement method
return null;
@Override
public DiskLocation prevDiskLocation d
TODO: implement method
return null;
@Override
public void insertDiskLocation d
TODO: implement method
@Override
public int height
TODO: implement method
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
