You are viewing a single comment's thread. Return to all comments →
I don't think thats how it is!!
According to me the output should rather be : 8 4 2 1 3..
I think all we need is to calculate the horizontal distance of each nodes from the root node and print the node and store them in the queue..then print the first node from the queue for each level of horizontal distance!