Question: please implement the following methods import java.util.Queue; import java.util.LinkedList; /** * * */ public class BinSrchTree >{ private static class BinNode { private T data;

 please implement the following methods import java.util.Queue; import java.util.LinkedList; /** *

please implement the following methods

import java.util.Queue; import java.util.LinkedList; /** * * */ public class BinSrchTree>{ private static class BinNode{ private T data; private BinNode left, right; public BinNode(){ left = null; right = null; }

public BinNode(T data, BinNode left, BinNode right){ this.data = data; this.left = left; this.right = right; } } private BinNode root; public BinSrchTree(){ root = null; } public BinSrchTree(T item){ root = new BinNode(item, null, null); } public boolean isEmpty(){ return root == null; }

public T first(){ } public T last(){ } public T higher(T item){ } public T lower(T item){ } public T ceiling(T item){ } public T floor(T item){ } public T pollFirst(){ } public T pollLast(){ } public int size(){ } public BinSrchTree subSet(T fromItem, boolean fromInclusive, T toItem, boolean toInclusive){ }

In this lab, we will work on adding more operations for BST. Java TreeSet is a balanced binary search tree. In addition to add, remove and search operations as what we have learned in our BinSrch Tree, it has a number of other operations. In this programming exercise, we will expand our BinSrchTree class with more similar operations from TreeSet class. Add the following instance methods to BinSrch Tree class in our unit example JavaBSTLinked and then test them in the driver program: T first() which returns the first (lowest) item currently in the tree I last() which returns the last (highest) item currently in the tree T higher (T item) which returns the least item in the tree strictly greater than the given item, or null if there is no such item T lower (T item) which returns the greatest item in the tree strictly less than the given item, or null if there is no such item I ceiling (T item) which returns the least item in the tree greater than or equal to the given item, or null if there is no such element T floor (T item) which returns the greatest item in the tree less than or equal to the given item, or null if there is no such item I pollFirst() which retrieves and removes the first (lowest) item, or returns null if the tree is empty I polllast() which retrieves and removes the last (highest) item, or returns null if the tree is empty int size () which returns the number of items in the tree (its cardinality) BinSrchTree subset (T fromItem, boolean from Inclusive, T toItem, boolean toInclusive) which returns a view of the portion of the tree whose items range from fromItem to toItem

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!