beyondgrader.com Logo
DemoBrowseAboutTeamLogin

BinaryTree to List

Geoffrey Challen // 2020.11.0

Create method toList that accepts a BinaryTree<Any> and returns a List<Any> containing all of the values in the tree, in any order.

Our suggestion is to have toList create the list and then call a private recursive helper method to populate it. You will need to import cs125.trees.BinaryTree. We've provided some code to get you started.

For reference, cs125.trees.BinaryTree is defined like this: