Count the number of trees in the forest stored using binary trees

Count the number of trees in the forest stored using binary trees

Because each tree has the right node of the previous tree, to the right dfs, each time a counter is found +1

int num=0;

void count(tree *p)
{
if(p==NULL)return;
num++;
count(p->r );
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324689162&siteId=291194637
Recommended