August 27, 2024
P61 - Count the leaves of a binary tree.
A leaf is a node with no successors. Write a method leafCount to count them.
scala
scala> Node('x', Node('x'), End).leafCount
res0: Int = 1
August 27, 2024
A leaf is a node with no successors. Write a method leafCount to count them.
scala
scala> Node('x', Node('x'), End).leafCount
res0: Int = 1
Don't have an account? We will create one for you.
Enter the OTP send to
in seconds.