Let the class BTNode represent a node of a binary tree that stores an int, as shown below: public class BTNode { private
Posted: Fri May 20, 2022 11:33 am
Let the class BTNode represent a node of a binary tree that stores an int, as shown below: public class BTNode { private int data; private BtNode left; private BTNode right; Il usual BTNode methods (getData, getLeft, getRight, Il setData, setLeft, setRight, constructor) 1/ Other methods } Write Java code for the following recursive BTNode method as efficiently as possible: public int setHeight () Set the data of each node to its height, where height of a node is the length of the longest path from that node to a leaf (i.e. number of nodes to be visited). All leaves have a height of O. Following is an example of a binary tree after it is called with setHeight on root of the tree. This problem has partial credit. However, if you write “don't grade" or leave the answer blank, we will not grade any of your work for this problem and you will receive 2 points. Salari 0 0