try this ....
do the DFS analogous traversal on the tree.....means
1.set level=1,push root
2.pop root
3.push both children on stack and set increment level  .
4.now pop top and recursively do the same thing

every time u pop an element enque it in a max priority queue according to
level
when traversal is over .....deque element from queue and print it till queue
is exhausted..
complexity :
O(nlogn) with O(n) xtra space

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