This can be done with level order traversal of the tree Algorithm
count = count2 = 0 1. Push the root in the queue. 2. keep count at each level for root count =1 3. while(queue not empty) 4. push all childs of node at the top of queue in queue 5. count2 += (number of childs of node at the top) 6. print the top node of queue and dequeue it 7. count -= 1 8. if (count == 0) 9. print newline 10. count = count2 11. count2 = 0 any comments are welcomed... -- Regards Jitendra Kushwaha Undergradute Student Computer Science & Eng. MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@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.