Question: 2. Assume that binary trees are implemented using a BinaryTreenode class that includes the following fields and methods: // fields private T data; private BinaryTreenode

 2. Assume that binary trees are implemented using a BinaryTreenode class

2. Assume that binary trees are implemented using a BinaryTreenode class that includes the following fields and methods: // fields private T data; private BinaryTreenode left, right // methods public T getData() public BinaryTreenodecT> getLeft) public BinaryTreenodecT> getRight() ( return data; ( return left;) return rights public void setRight (BinaryTreenodecT> newR) right new; ) Write the findNegatives method whose header is given below. public static List findNegatives( BinaryTreenodecInteger> n) The method should return a list containing all the negative values in a binary tree containing Integer data. For example, if the tree pointed to by n looks like this: -6 45 9 8 1 7 -32 f indNogatvea (n) should return a list containing-6,-4.-1, and-3 (not necessarily in this order). If the same value appears more than once in the tree, it should also appear more than once in the result list. Part A: First, complete the English descriptions of the base and recursive cases, like what was given above for Question 1. o The list of negative values in an empty tree is the empty list. o The list of negative values in a tree with one node is (hill in your answer here) o The list of negative values in a tree with more than one node is (fill in your answer here) e findNegatives method. You may assume that the List used to hold negative values is implemented as an Part B: Now write th Arraylist

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!