二叉树最长路径

int maxDepth(struct node* node) 
{
   if (node==NULL) 
       return 0;
   else 
   {
       /* compute the depth of each subtree */
       int lDepth = maxDepth(node->left);
       int rDepth = maxDepth(node->right);

       /* use the larger one */
       if (lDepth > rDepth) 
           return(lDepth+1);
       else return(rDepth+1);
   }
} 
    原文作者:lintong
    原文地址: https://www.jianshu.com/p/7e9d64949a06
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞