c++ - Finding the height of a multiway tree -
How can you find the height of multi-tree trees? If I wanted to find the height of binary tree, then I could do something like this:
int height (node * root) {if (root == NULL) 0; And maximum return (height (root-> left), height (root-> right)) + 1; }
But I'm not sure that I can implement the same recurring method in the multiview tree.
Common case will be:
int height (node * root) {If (root == NULL) 0; Else {// pseudo-code int max = 0; For every child {int height = height (child); If (height; max) max = height; } Return Maximum + 1; }}
Comments
Post a Comment