use this

verticalSum(node *root, List *l)
{
    if(root == null) return;
    root->n += l->n;

   // check for l->left, l->right and if null, allocate and link them
    verticalSum(root->left, l->left);
   verticalSum(root->right, l->right);
}

On Aug 25, 8:20 pm, Anup Ghatage <[email protected]> wrote:
> If I'm not mistaken what you are doing is assigning column indices to each
> node.
> 0 to the root and every time it goes to the left you subtract one and every
> time it goes to the right you add one... correct?
>
> It will fail for this example:
>                                  12
>                                 /    \
>                               /        \
>                              6         8
>                            /   \       /  \
>                           /     \     /    \
>                         13   10  1     90
>                               /   \       /  \
>                             /     \     /    \
>                          14   15  16    17
>                         /   \       /  \
>                        /     \     /    \
>                      17  18  19   20
>                     /   \       /  \
>                    /     \     /    \
>                 21     22  23   24
>
>
>
>
>
>
>
>
>
> On Thu, Aug 25, 2011 at 8:06 PM, Shravan Kumar <[email protected]> wrote:
> > @Anup
>
> > Can you please elaborate why it will not work?
>
> > On Thu, Aug 25, 2011 at 8:02 PM, Anup Ghatage <[email protected]> wrote:
>
> >> Naren:
> >> It wont work for tree's of level > 3 and non-complete binary trees
>
> >> On Thu, Aug 25, 2011 at 6:49 PM, Naren s <[email protected]> wrote:
>
> >>> let intialize the count be equal to zero and pass it to left nodes as
> >>> well as right nodes.
>
> >>> verticalsum(struct node* node,int count)
> >>> {
> >>> verticalsum(node->left,count-1);
> >>> hash(count)+=node->data;
> >>> verticalsum(node->right,count+1);
>
> >>> }
>
> >>> On Wed, Aug 24, 2011 at 9:18 PM, Nikhil Veliath <[email protected]>wrote:
>
> >>>> find the vertical sum of a binary tree .  .  . wat do we mean by
> >>>> vertical sum anyone any help
>
> >>>> --
> >>>> 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.
>
> >>> --
> >>> *Narayanan S,*
> >>> B.E., C.S.E., (final year),
> >>> College Of Engineering Guindy,
> >>> Anna University,
> >>> Chennai-25.
>
> >>>  --
> >>> 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.
>
> >> --
> >> Anup Ghatage
>
> >>  --
> >> 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.
>
> --
> Anup Ghatage

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