Question: -Implement the methods insert, remove, find and print in the BoundedAVL class - The tree is stored in parallel arrays -The methods must call private
-Implement the methods insert, remove, find and print in the BoundedAVL class - The tree is stored in parallel arrays -The methods must call private recursive methods that do most of the work. You have to figure out the signatures of the private methods. import java.util.*; import java.io.*; public class BoundedAVL { //Implements an AVL tree of ints stored in parallel arrays //There are no duplicates in the tree private int root; private int free; private int left[]; private int data[]; private int right[]; private int height[]; private int maxIndexUsed; public BoundedAVL(int size) { root = -1; free = -1; left = new int[size]; data = new int[size]; right = new int[size]; height = new int[size]; maxIndexUsed = -1; } public boolean full() { return maxIndexUsed == data.length-1 && free == -1; } public void insert(int d) { //PRE: the tree is not full //if d is not in the tree insert d otherwise the tree does not change //if space is available in the free list then the first item on the free list //must be used to store the new node } public void print() { //print a comma delimited list of pairs, (data, height),of values in the tree in //ascending order of the data on one line. a newline should be printed at the end of the //line for example (10,0), (25,1), (40,0),(50,3), (60,1), (70,0), (76,2), (80,0) } public void remove(int d) { //if d is in the tree remove d and add the node containing d to the free list //if d is not in the tree do nothing } public boolean find(int d) { //if d is in the tree return true otherwise return false } } - Add instance variables and methods as needed - For each instance variable and method add a comment describing the purpose or use of the variable or method
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
