An empty binary search tree has zero nodes; a nonempty node contributes one in addition to the sizes of its two subtrees:
size :: STree a -> Integer
size = foldSTree (\left _ right -> 1 + left + right) 0The answer is . The tree fold visits every node once, so this takes arithmetic operations for nodes.
Articles by others on the same topic
There are currently no matching articles.