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?
--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---