August 27, 2024
P61A - Collect the leaves of a binary tree in a list.
A leaf is a node with no successors. Write a method leafList to collect them in a list.
scala
scala> Node('a', Node('b'), Node('c', Node('d'), Node('e'))).leafList
res0: List[Char] = List(b, d, e)