In Java
QUIZ
MAP
Programming Questic
Binary Tree Leaves All Odd
Complete a public class named BinaryTreeTester that provides a single class method named leavesAllOdd. leavesAllOdd accepts a BinaryTree<Integer> and returns true if all the leaf nodes in the tree store odd values. Otherwise, return false. If the tree passed to leavesAllOdd is null, throw an IllegalArgumentException.
You will need to provide a recursive helper method for this problem. Approach this problem in the same way as we have approached other recursive tree problems. However, note that you will need to identify leaf nodes in your recursive method so that you can inspect their values properly.
For reference, cs125.trees.BinaryTree has the following public properties:
public class BinaryTree {
public Object getValue() // returns the value
public BinaryTree getRight() // returns the right node
public BinaryTree getLeft() // returns the left node
}
WORKING
PREVIOUS