Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions