if its only printing the values then
int get_height(node temp)
{
if(temp!=NULL)
{
return(get_height(temp->L)>get_height(temp->R)?(get_height(temp->L)+1):(get_height(temp->R)+1));
}
return 0;
}
void get_width(node temp, int level,int direction)
{
if(temp==NULL) return 0;
if(level==1) {printf("%d",temp->data);}
if(level>1)
{
if(direction)
{
get_width(temp->L,level-1,direction);
get_width(temp->R,level-1,direction);
}
else
{
get_width(temp->R,level-1,direction);
get_width(temp->L,level-1,direction);
}
}
}
int max_width()
{
int height,i;
int width=0,maxwidth=0,level;
height=get_height(root);
for(level=0,i=0;i<=height;i++,level++)
{
width=get_width(root,level,i%2);
}
return(maxwidth);
}
Thank you,
Sid.
On Sun, Aug 28, 2011 at 10:58 PM, Kunal Patil <[email protected]> wrote:
> @ Kartikeyan:
> If you use normal queue implementation how you are going to print
> reverse???
> (From ptr2 to ptr1)...If you are implementing queue in an array, then your
> solution can be feasible..
> If not in array, you must modify your queue DS to include pointers to
> previous elements.
> Or you can do this by emptying queue into stack n then printing nodes...
> Am I getting it correct? Or is there anything I am missing?
>
> --
> 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.
>
--
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.