Doesn't the solution without queue look very inefficient? The tree is being traversed till level n-1 for every Nth level printing. Thus if the tree has height h, then h^2 tree traversals are there.
Nodes being accessed at level l (assuming fully balanced tree): 1 + 2 + 4 + 2^l = 2^(l+1) - 1 which is O(2^l) Thus complete order is: h + (h-1)*3 + (h-2)*7 + ... (h-k)*2^k -- 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.