change the info part of each node in binary tree i have a binary tree.

         2
       /   \
      3     4
     / \     \
    5  1      8
     \       /
     6      9


I want to change the info part of each node such that the

nodeinfo = nodeinfo + nextInorderNodeInfo


so the actual inorder traversal

5, 6, 3, 1, 2, 4, 9, 8


will change to

5+6,6+3,3+1,1+2,2+4,4+9,9+8,8+0 

11, 9,  4,  3,  6,  13, 17, 8


i need to write a function that will modify the binary tree info parts of each node.

i have done the following

calling 

change(root,NULL);


function definition

void change(node* n, node *k)
{
 if (n) 
  { 
    if (n-&gt;left) change(n-&gt;left,n);
    if (n-&gt;right) change(n,n-&gt;right);
    n-&gt;info + = k-&gt;info;
  }
} 


in this way i am not able to modify the nodes that are right hand leaf nodes.

can someone give the correct solution..???

thanks in advance
In my point of view, since you want to use the next info in the inorder traversal, you have to do a function that traverse you tree backward for this order.

    int change(node* n,int next){
     int k;
     k=next;
     if(n){
      if(n-&gt;right) k = change(n-&gt;right,next);
      if(n-&gt;left) change(n-&gt;left,n-&gt;info);
      n-&gt;info += k;
     }
    }


That way, calling

     change(root,0)


You have next that is the info of the next node in your order.

I hope I didn't made a mistake and that it help.