Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * * * See the spec on the website for tips and example behavior. * * Also note: you may want to use private
See the spec on the website for tips and example behavior.
Also note: you may want to use private helper methods to help you solve these problems.
YOU MUST MAKE THE PRIVATE HELPER METHODS STATIC, or else your code will not compile.
This happens for reasons that aren't the focus of this assignment and are mostly skimmed over in
and If you want to know more, you can ask on the discussion board or at office hours.
REMEMBER THE FOLLOWING RESTRICTIONS:
do not call any methods on the IntTree objects
do not construct new IntTreeNode objects though you may have as many IntTreeNode variables
as you like
do not construct any external data structures such as arrays, queues, lists, etc.
do not mutate the data field of any node; instead, change the tree only by modifying
links between nodes.
public class IntTreeProblems
Computes and returns the sum of the values multiplied by their depths in the given tree.
The root node is treated as having depth
public static int depthSumIntTree tree
TODO replace this with your code
throw new UnsupportedOperationExceptionNot implemented yet.";
Removes all leaf nodes from the given tree.
public static void removeLeavesIntTree tree
TODO replace this with your code
throw new UnsupportedOperationExceptionNot implemented yet.";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started