On 2 říj, 16:07, Manisha <pgo...@gmail.com> wrote:
> Traversing a binary tree from bottom to top
>
> The only way I could think of is:
> Traverse the binary tree from top to bottom, level by level with the
> help of queue.
>   For a tree like:
>                     a
>              b             c
>           d     e               g
> The Queue will be something like:
>      a b c d e g
> Now de-queue the element one be one from queue and push on stack.
> Pop the stack one by one to get deserved output:
> g e d c b a
> This will take o(n) space and o(n)time. Is there any better way of
> doing it?
There exists the Pruefer algorithm for trees, based on their pruning,
expressing trees as strings of symbols. It is valid also for binary
trees.
kunzmilan
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to