@Minotauraus

I feel Queue gives more picture.

Thanks,
Sathaiah Dontula

On Thu, Jul 29, 2010 at 3:53 AM, Minotauraus <anike...@gmail.com> wrote:

> Width of a Tree = maximum number of nodes at the same level.
> Example:
>                            a
>                       b        c
>                     d  e      f  g
>                        h      i j
>
> Here, the max. width is 4 at level 3->d, e, f, g
>
> Algo to find width:
>
> 1. Push node on stack1
> 2. Pop node from stack1 if not empty
> 3. visit node and push children on stack2
> 4. goto 2 if stack1 not empty
> 5. if stack1 empty, number of elements in stack 2>width  then width=
> number of elements on stack2
> 6. repeat steps 2-5 for stack2
>
> basically keep pushing children on stack until 1 stack is not empty,
> the value when it is empty will give the width at that level.
> Use one variable to store this width by checking if current width is
> greater.
>
> -Minotauraus.
> On Jul 26, 5:23 am, umesh kewat <umesh1...@gmail.com> wrote:
> > use levelorder traversal and  calculate the number of node in same level
> by
> > putting some condition :)
> >
> > On Mon, Jul 26, 2010 at 1:53 PM, vineel yalamarth <
> >
> >
> >
> >
> >
> > vineelyalamar...@gmail.com> wrote:
> >
> > > No dude, they asked me to find width , in the sense ... find the
> maximum
> > > number of nodes in any level.
> > > And if you know how to find the diameter do post it....
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to algoge...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> <algogeeks%2bunsubscr...@googlegroups­.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/algogeeks?hl=en.
> >
> > --
> > Thanks & Regards
> >
> > Umesh kewat- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> 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 algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to