N JAVA PLS Create a public class BinaryTreeToMap that provides a single static method toMap. toMap accepts a BinaryTree and returns a Map mapping the values in the tree to the count of the times that the value appears. Our suggestion is to have toMap create the map and then call a private recursive helper method to populate it. If the tree passed to toMap is null you should throw an IllegalArgumentException. You will need to import cs125.trees.BinaryTree, as well as Map and a Map implementation (probably HashMap) from java.util. We've provided some code to get you started.
IN JAVA PLS
Create a public class BinaryTreeToMap that provides a single static method toMap. toMap accepts a BinaryTree<?> and returns a Map<Object, Integer> mapping the values in the tree to the count of the times that the value appears.
Our suggestion is to have toMap create the map and then call a private recursive helper method to populate it. If the tree passed to toMap is null you should throw an IllegalArgumentException. You will need to import cs125.trees.BinaryTree, as well as Map and a Map implementation (probably HashMap) from java.util. We've provided some code to get you started.
For reference, cs125.trees.BinaryTree has the following public properties:
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images