1 1 vote int A(struct node* node) { if (node==NULL) return 0; else { int lDepth = A(node->left); int rDepth = A(node->right); /* use the larger one */ if (lDepth > rDepth) return(lDepth+1); else return(rDepth+1); } } Programming in C self-made algorithms binary-tree + – Aghori 771 views answer comment Share Follow Print See 1 comment 1 1 comment reply Deepak Kumar 12 commented Jul 4, 2017 reply Follow flag Above Code segment calculate height of tree. 1 1 replyShare Please log in or register to add a comment.
0 0 votes At every node function call is made. It returns the number of levels in tree or height of tree if we consider root at level-1. Such questions can be answered by taking small tree and see what function returns. Rahul Jain25 answered Jul 4, 2017 Rahul Jain25 comment Share Follow 0 reply Please log in or register to add a comment.