Menu

[Solved]Bstwithduplicatesjava Binary Search Tree Must Ability Contain Duplicate Entries Place Dupl Q37123716

The BSTWithDuplicates.java is a binary search tree that musthave the ability to contain duplicate entries. Place the duplicateof an entry in the entry’s right subtree. Refer to the code that isprovided to you, and complete all the methods that have the TODOstatements.

package ;
import java.util.ArrayList;
import java.util.List;

public class BSTWithDuplicates<T extendsComparable<T>>
{
   BinaryNode root;
   public BSTWithDuplicates()
   {
       super();
   }

  
   private class BinaryNode
   {
       /*
       * You are not required to add anynew
       * instance variables or methods toBinaryNode
       * class.
       */
       T data;
       BinaryNode left;
       BinaryNode right;
      
       private BinaryNode(T rootEntry){
          data=rootEntry;
       }
      
   }
  
   /*
   * We have completed the constructor ofBSTWithDuplicates
   * for you.
   */
   public BSTWithDuplicates(T rootEntry)
   {
       root=newBinaryNode(rootEntry);
   }

  
   /*
   * TODO: Write a method called getMin that returns backthe minimum
   * of the binary search tree. You can use recursion orno recursion for
   * this method.
   */
   public T getMin()   
   {
      
           returnnull;
   }
  
   /*
   * TODO: Write a method called getMax that returns backthe maximum
   * of the binary search tree. You can use recursion orno recursion for
   * this method.
   */
   public T getMax()
   {
  
         
       return null;
   }
  
   /*
   * TODO: Write a method called getEntry that returnsback the data (of type T)
   * if entry is in the binary search tree. If there areduplicates of entry, getEntry
   * must return back the first occurance of entry. Youmust use recursion to solve this.
   * Feel free to create a helper method that does therecursion for you.
   */
   public T getEntry(T entry)
   {
       return null;
   }

      
   /*
   * TODO: Write a method called getAllEntry that returnsback all data (of type T) for
   * entry. All the occurances of entry must be putinside an ArrayList.
   * If there is no entry, then you return backnull.
   * You must use recursion to solve this.
   * Feel free to create a helper method that does therecursion for you.
   */
   public ArrayList<T> getAllEntriesEqualTo(Tentry)   // *
   {
       return null;
   }
  
   /*
   * TODO: Write a method called contains thatchecks
   * whether a entry of type T is present in the binarysearch tree with duplicates
   * or not. If it is present return back True orotherwise return back False.
   * This method must call getEntry.
   */
   public boolean contains(T entry)
   {
       return false;
   }

   /*
   * TODO: Write a method called add
   * that adds newEntry onto the binary tree withduplicates.
   * This method must use recursion. Feel free to createanother helper method
   * that does the recursion for you.
   */
   public T add(T newEntry)
   {  
       return null;
      
   }
  
}

Expert Answer


Answer to The BSTWithDuplicates.java is a binary search tree that must have the ability to contain duplicate entries. Place the du… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *