I should mention it's a binary tree, not necessarily complete. Though, i don't think BFS search has anything to do with tree being complete. Child's position will be calculated from parent positions.
leftchildX = parentX - value(based on level) rightchildY = parentY + value(based on level) On Aug 28, 7:57 pm, Sanjay Rajpal <[email protected]> wrote: > It is basically BFS for this tree, just maintain spaces at each level > provided tree is a complete binary tree. > > Sanju > :) > > On Sun, Aug 28, 2011 at 7:46 AM, Navneet Gupta <[email protected]>wrote: > > > > > > > > > Hope the question is clear. Basically you need to print a given tree > > such that spaces will depict the left/right relation at every level. > > > output should be something like > > a > > b c > > d e f g > > > Levels are separated by new lines. Notice that space between nodes at > > higher levels increases with the number of levels we have. Assume a > > max of 10 levels. But the algorithm should scale. > > > -- > > Regards, > > Navneet > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
