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

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -