Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Each node in the DupBinarySearchTree has its info, and three pointers: left ( lLink ) , middle ( mLink ) and right ( rLink )
Each node in the DupBinarySearchTree has its info, and three pointers: left lLink middle mLink and right
rLink links to point to nodes whose info are less than, exactly equal and greater than the current node. For
instance, the root with info has three links corresponding to nodes with info and as indicated in the
picture while the node with info and its three duplicates has only one middle link. The definition of tree height
on a BST also applies on DupBinarySearchTree. However, this tree only allows at most duplicate copies of
any node an error message should be generated if any node has more than copies
Refer to Lecture for all the necessary classes. The client ClientDupBST.java is included to test your
program. Type parameter generic data type is required for all classes. Recursion is allowed for the final
exam. Keep in mind, there can and will be unexpected errors if you simply copy and paste code from the
lecture.
You will need to implement the following methods whose descriptions are given in the interface and the files.
Apts total In file DupBinaryTreejava
pts The default constructor.
pts The alternative constructor.
pts The helper method printDistinct for function printSortedTreeWithoutDuplicates
pts The helper method printDup for function printSortedTreeWithDuplicates
pts The helper method height for function treeHeight
pts The helper method isDupBST for function isDupBinarySearchTree
Bpts total In file DupBinarySearchTreejava
pts The helper method reSearch for function search
pts The helper method recInsert for function insert
pts The helper method recDelete for function delete
pts A method named findClosest T key to return the node whose information is the closest in
absolute distance to the provided key. For example, in the above tree with information of type Double,
and key the closest node is the one with information Write code to test this method in the
provided client
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started