Height of binary tree


/*The tree node has data, left child and right child
struct node
{
    int data;
    node* left;
    node* right;
};

*/
int max(int a,int b)
    {
    if(a>b)
        return a;
    else
        return b;
}
int height(node * root)
{
  if(root==NULL)return 0;
    else
        return 1+max(height(root->left),height(root->right));
}
 

Comments

Popular posts from this blog

How whatsapp works

ABOUT WHATSAPP

Edit Java Class file at runtime