it can be done by bfs with slight modification. so in bfs we use queue we
have to add a dummy node in queue. So this node will tell us that end of
level has come.so we can find out the no of node at any level using bfs.

On Sun, Aug 21, 2011 at 1:34 AM, Dave <dave_and_da...@juno.com> wrote:

> @Sagar: The problem doesn't say that the tree is complete. The number
> of nodes in level i can be anything between 1 and 2^i. The question is
> asking how to count the nodes in each level efficiently.
>
> Dave
>
> On Aug 20, 3:00 pm, sagar pareek <sagarpar...@gmail.com> wrote:
> > and total number of nodes( leaves+internal ) present in a ith level tree
> is
> > 2^(i+1)-1
> >
> >
> >
> >
> >
> > On Sun, Aug 21, 2011 at 1:28 AM, sagar pareek <sagarpar...@gmail.com>
> wrote:
> > > 2(power)i  or 2^i
> > > where i is level  i=0,1,2,3..........
> >
> > > On Sun, Aug 21, 2011 at 1:27 AM, bugaboo <bharath.sri...@gmail.com>
> wrote:
> >
> > >> Anyone knows the algorithm to count the number of nodes at each level
> > >> in a binary tree. Providing the approach and logic better than the
> > >> actual code itself.
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Algorithm Geeks" group.
> > >> To post to this group, send email to algogeeks@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.
> >
> > > --
> > > **Regards
> > > SAGAR PAREEK
> > > COMPUTER SCIENCE AND ENGINEERING
> > > NIT ALLAHABAD
> >
> > --
> > **Regards
> > SAGAR PAREEK
> > COMPUTER SCIENCE AND ENGINEERING
> > NIT ALLAHABAD
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@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