Quantcast
Channel: Get deep of a logic hierarchical structure - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Shivam for Get deep of a logic hierarchical structure

$
0
0

Considering you've node with reference of parent_node then function deep could implemented as follows:

(Each node has id & data property)

int deep(node *n) {    /* deep of root node is zero and that's our base case */    if(n->parent_node.id == 0)        return 0;    return 1 + deep(n->parent_node);}

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>