Question: For the given Binary Search Tree class, implement a method (checkChild Count) that takes a node X in the tree and it returns an integer

 For the given Binary Search Tree class, implement a method (checkChild

For the given Binary Search Tree class, implement a method (checkChild Count) that takes a node X in the tree and it returns an integer value based on the following rules: if the number of children of X on the left subtree is the same as the number of children on the right subtree, the function will return 0 if there are m more children on the left side than on the right side, it will return m if there are m more children on the right side than on the left side, it will return -m The tables below show the results of calling this method on btrl and btr2 objects that run on two binary search trees separately, 61 Output 1 40 75 -1 Method Call btrl.checkChildCount((BNode) 61 ) btrl.checkChildCount ((BNode) 75) btrl.checkChildCount((BNode) 40 ) btrl.checkChildCount ((BNode) 13) btrl.checkChildCount ((BNode) 80 ) 0 13 55 80 0 0 20 Output 0 10 25 Method Call btr2.checkChildCount (BNode) 20 ) btr2.checkChildCount((BNode) 25 ) btr2.checkChildCount ((BNode) 10 ) | btr2.checkChildCount ((BNode) 15) btr2.checkChildCount (BNode) 40) 15 30 -2 -2 1 0 13 40 a) You will write a public method checkChildCount that will become part of the BST class. You cannot construct any extra data structures to solve this problem. (20p) public class BNode ( public int key; // data stored in this node public BNode left: // reference to left subtree publie BNode right; / reference to right subtree public class BST private BNode Root, public int checkchildCount (BNode bn) Whats Ann Image inea

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!