Create a public class TreeCombineStrings that provides a single
class method named combineEvenStrings. combineEvenStrings accepts a single
BinaryTree<String>. If the passed tree is null, throw an
IllegalArgumentException. Otherwise, return the concatenation
of all even length Strings in this tree, in the order
current + left + right (post-order traversal).
For example, given the tree:
"12"
/ \
"cs" "4"
You would return "12cs", by concatenating the current node "12",
the left subtree "cs", and the right subtree "" (the right subtree has
no even length Strings). If the tree was:
"24"
/
"1"
\
"cs"
You would return "24cs", by concatenating the current node "24", and
the left subtree "cs" (you ignore "1" because it is not even length).
You may need to write a private helper method
to solve this problem.
For reference, cs125.trees.BinaryTree has the following public properties:
You're challenge is to write tests for this problem described above.
Stuck? You may find these lessons helpful: