Trees and depth
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?
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
Popular Topics
Advertisement