Question: Q4. Consider the following declaration of the TreeNode class, which also has the getData(). getleft() getRight() and SetAlINull() public methods: public class TreeNode ( private

Q4. Consider the following declaration of the "TreeNode" class, which also has the getData(). getleft() getRight() and SetAlINull() public methods: public class TreeNode ( private Integer data; private TreeNode left; private TreeNode right; A binary tree can then be represented by its root only as: TreeNode root; Write recursive implementations for the following methods on the binary tree: a. I1 Input: p, root pointer of a binary tree which may be null // Postcondition: All nodes at the root and below are deleted. public void treeclear (TreeNode p) f b. I Input: P, root pointer of a binary tree which may be null // Postcondition: The data from the nodes of the tree have been // printed using in-order traversal. public void printTree (TreeNode p) f
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
