subtree_size¶
-
visualife.diagrams.subtree_size(root: visualife.diagrams.TreeNode.TreeNode)¶ Calculates size of every subtree of a give tree
This function uses recursion to compute the size of a subtree rooted at every node of a given tree. :param root: (
TreeNode) - the root of an input tree :return: (dict) - a dictionary where anidof a tree node is a key and the size of the respective subree is the value associated with that tree