Question: (JAVA) (30 points) A binary tree is a data structure that is composed of nodes containing values In addition, each node has at most two

(JAVA)  (JAVA) (30 points) A binary tree is a data structure that
is composed of nodes containing values In addition, each node has at

(30 points) A binary tree is a data structure that is composed of nodes containing values In addition, each node has at most two children, referred to as the left child and the right child. The top most node is called the root of the tree and the bottom nodes are called leaves. The size of the tree is the total number of its nodes. 6. For example, the binary tree below contains integer values. It is of size 9 and it has a root with value 2 and leaves with values 2, 5, 11, and 4. 2 2 6 9 11) 4 Figure 1 image by Derrick Coetzee, released to the public domain Write a generie class named BinaryTree with the following specification .BinaryTree has one public constructor creating an empty binary tree .BinaryTree has the method public int size) which returns the number of nodes in the tree. BinaryTree has the method public void addNode (E e) which adds a node as a leaf in the next available location, from top to bottom then left to right. For example, if a current tree contains only a root, then the new node will be added as the left child. Similarly, for the following tree 2 2 6 The new node will be added as the left child of the node with the value 5 . BinaryTree has the method public E removeNode ) throws EmptyBinaryTreeException which retrieves and removes the node that was added last. This node is also the bottom rightmost leaf among all the leaves in the tree. Your method should throw a EmptyBinaryTreeException if BinaryTree is empty. You will need to create a suitable class for the exception

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!