vertical_traversal(v)
{
  stack_init(vstack);
  stack_init(tstack);

  while(v)
      stack_push(vstack, v);
      if(v.right)
          stack_push(tstack, v.right);
      v = v.left;

  while(! is_empty(vstack))
      visit(stack_pop(vstack));
  while(! is_empty(tstack))
      vertical_traversal(stack_pop(tstack));
}


On 2010-6-9 16:56, sharad wrote:
can any one tell me how to code for vertical level traversal of a
binary tree?????


                                               1
                                             /    \
                                            2      3
                                          /   \    /  \
                                         4    5  6    7


print

4   2    1    5    6   3    7


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

Reply via email to