Problem 62a Solutions

Solution 1

countInternals : Tree a -> Int
countInternals tree =
    case tree of
        Empty ->
            0

        Node v left right ->
            if left == Empty && right == Empty then
                0
            else
                1 + countInternals left + countInternals right

Back to problem

results matching ""

    No results matching ""