August 26, 2024
P71 - Determine the internal path length of a tree.
We define the internal path length of a multiway tree as the total sum of the path lengths from the root to all nodes of the tree. By this definition, the tree in the figure of problem P70has an internal path length of 9. Write a methodinternalPathLengthto return that sum.
> "afg^^c^bd^e^^^".internalPathLength
res0: Int = 9