Question: 13. Using the BTNode class from Chapter 9, write a new static method of the BTNode class to meet the following specification. Short Answers Section
13. Using the BTNode class from Chapter 9, write a new static method of the BTNode class to meet the following specification. Short Answers Section 9.4 Tree Traversals public static int manyNodes(BTNode root) // Precondition: root_ptr is the root reference of a binary tree. // Postcondition: The return value is the number of nodes in the tree. // NOTES: The empty tree has 0 nodes, and a tree with just a root has // 1 node. 14. Using the BTNode class from Chapter 9, write a new static method of the BTNode class to meet the following specification. public static int treeDepth(BTNode root) // Precondition: root_ptr is the root reference of a binary tree. // Postcondition: The return value is the depth of the binary tree. // NOTES: The empty tree has a depth of -1 and a tree with just a root // has a depth of 0.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
