Question: Implement a recursive method namrd public int depth(BTNode n, int d) where n is the current node and d is the depth of the node.
Implement a recursive method namrd public int depth(BTNode n, int d) where n is the current node and d is the depth of the node. The method returns the length of the longest path from node n to a leaf in its subtree.
public class BTNode private int value; private BTNode rnode; private BTNode 1node; 1ic BTNode (int v) f value - v; rnode- null; 1node - null; public int getvalue() f return (value) ;H public BTNode public BTNode getlnode () f return (1node); public void setvalue (int v) { value = v; } public void setrnode (BTNode r) (rnode r;) public void setlnode (BTNode 1) (lnode 1;) getrnode () return (rnode) public class BST private BTNode root; (10) Implement a recursive int largest(BTNode n) that returns the largest v alue ubtree whose root node is n of (15) Implement a recursive method named public int addinorder(BTNode n) that returns the su all of the values stored in the subtree of nodern (20) Implement a recursive method named public int depth(BTNode n, int d) where n is the current node and d is the current depth of the node. The method returns the length of the longest path from node n to a leaf in its subtree 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
