Write a C program to compute the maximum depth in a tree?

Here is some C code...

  1. int maxDepth(struct node* node)
  2. {
  3. if (node==NULL)
  4. {
  5. return(0);
  6. }
  7. else
  8. {
  9. int leftDepth = maxDepth(node->left);
  10. int rightDepth = maxDepth(node->right);
  11. if (leftDepth > rightDepth) return(leftDepth+1);
  12. else return(rightDepth+1);
  13. }
  14. }