Maximum complete level of a binary tree

Given a binary tree, find the maximum level at which tree is completely filled.

int getMaxCompleteLevel(node* node){
if(node==NULL||!(node->left)||!(node->right))
return 0;
int l=getMaxCompleteLevel(node->left);
int r=getMaxCompleteLevel(node->right);
return 1+min(l,r);
}

Leave a comment