Trees and depth

Started by
20 comments, last by jtech 22 years, 1 month ago
Well, gosh darn it. I think I provided a solution above. Is anybody going to comment on it, criticize it, or at least thank me?
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.
Advertisement

I''m still trying to figure it out

I got the code written to find the max num of descendants for
each node, but the second part is little murky.

Here''s what I got:

  typedef struct _NODE { INT num_nodes; struct _NODE *nodes;} NODE;INTGet_Num_Descendants( NODE *parent, INT parent_depth ) { if(NULL == parent) {    return parent_depth; } INT max=0; for(INT i=0; i < parent->num_nodes; i++) {     if(parent->nodes[i]) {       INT d = Get_Num_Descendants( parent->nodes[i], (parent_depth+1) );       max = MAX( max, d );    } } max = MAX( max, parent_depth ); return max;}  

This topic is closed to new replies.

Advertisement