int treeMaxHeight(int index)
{
if(tree[index]==NULL)
return 0;
else
{
return 1+max(treeHeight(2*index),treeHeight(2*index+1));
}
}
int treeMinHeight(int index)
{
if(tree[index]==NULL)
return 0;
else
{
return 1+min(treeHeight(2*index),treeHeight(2*index+1));
}
}
if(treeMaxHeight(1)-treeMinHeight(1)>1)
then not "balanced";
else
"Balanced";
On Wed, Jul 4, 2012 at 8:53 AM, Ashish Goel <[email protected]> wrote:
> WAP to find if a tree is balanced/fully balanced?
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
Thanks & Regards
Amritpal singh
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.