This is a blog about arity of trees. Arity is the number of maximum children a node can have. It applies to trees. A binary tree have arity of 2 because it only have left and right tree. Trees can have a number of arity.
We learned that I can use a recursive method to find arity. The base case is i have no children which means that I return an arity of 0 and the induction case is that I call the function on every children of the node and append the number of children of this node. Then I call the max function on it. Eventually we will have the arity of the whole tree.
No comments:
Post a Comment