Finding the child node in the recombining binomial tree I am trying to program a binomial tree in Matlab. The tree looks something like this:

The numbers in the picture refer to the index of the array to create a binomial tree.
Problem:
Value of 2 = 0.5*Value of 4 + 0.5*Value of 5
Value of 3 = 0.5*Value of 5 + 0.5*Value of 6
I need to link the value of 2 to value of 4 and value of 5, similarly for value of 3 accordingly. 
How do i get the link mathematically so that I can program it, instead of stating it manually?
I hope the problem is clear. Need some guidance on this.
How I am programming it?
Basically I am trying to model an interest rate tree. I am having a array for interest and another for the discounted value. I have a previous qn:Interest Rate Tree in Matlab. Now I am changing to vectors.I programmed it using cell arrays, now changing to vectors.
Interest = [0.03;0;0];
DiscountedValue =zeros(3,1);

Interest = [Interest; zeros(n,1)];
DiscountedValue = [DiscountedValue; zeros(n,1)];

total= size(Interest,1);
DiscountedValue(end:-1:(end-n+1)) = 100;
m=0
for i=total-n:-1:total-2n+2
        Interest(i)= (alpha*exp(2^(m)*volatility))/100;
        m = m+1;
end
for j= total-n:-1:1
    //Stuck here//DiscountedValue(j) = (0.5*DiscountedValue(j+0.5*DiscountedValue{j+1}(2,i+1))/(1+Interest(j));
end


The bottom numbers on your columns are the triangular numbers $\frac 12n(n+1)$ where $n$ is the column number.  If you have a number, say $5$, the number up and to the right is $5+n$, where $n$ is the column number of $5$ and the number down and to the right is $5+n+1$.  We will be done if we can find the column number from the entry.  
Given a triangular number $m$, its column number is the $n$ such that $m=\frac 12n(n+1)$ or $n^2+n-2m=0$  We can use the quadratic formula to solve this:  $n=\frac 12(-1+\sqrt{1+8m})$  So given an entry $m$ in your triangle, its column number is $\lceil \frac 12(-1+\sqrt{1+8m}) \rceil$  
For a test, let $m=13$.  It column number is $\lceil \frac 12(-1+\sqrt {1+8\cdot 13})=\lceil \frac 12(\sqrt{105}-1 )\rceil=\lceil \frac 12(10.25-1) \rceil =5$ and the numbers next to it are $18,19$
