# Is there a more efficient data structure to implement binomial trees than 2d array?

I'm just curious what is the "industry standard" for implementing a binomial tree (if "standards" exist in this case). For simplicity, let's just talk about the simplest trees with recombining nodes.

Personally, I've been using 2d arrays/matrices, in particular upper-triangular matrices to implement binomial trees. I'm using Python so numpy.ndarray becomes the obvious way to go. I'm not seeing any big problem with this (you are welcome to point out the disadvantages of using ndarray for this job in your opinion).

Besides 2d arrays, what are the other efficient ways/data structures to implement the binomial tree? It would be especially appreciated if anyone can kindly provide their "industry inisights" to this problem. Thanks!

• Two 1 dimensional arrays are usually sufficient: cnew and cold. At each iteration you use the entries in cold to compute cnew, this corresponds to one step back in time in the tree. Then you copy from cnew to cold in preparation for the next iteration. Commented Feb 5, 2019 at 17:07
• @AlexC fair point. If we only need the price, we actually don't have to store the whole tree.
– Vim
Commented Feb 5, 2019 at 17:10
• On the other hand, good luck debugging a problem if you have erased all the intermediate results ;) Commented Feb 5, 2019 at 17:50
• Usually 1d array is sufficient for binomial tree if you do one pass only
– Ezy
Commented Feb 5, 2019 at 20:26
• Perhaps 'Implementing Binomial Trees' (ssrn.com/abstract=1341181) is useful. The paper explains that 1d arrays suffice, as already mentioned by Alex C. It also discusses how to get (some) Greeks directly from the tree, and vectorization. (Disclosure: I am one of the authors.) Commented Feb 6, 2019 at 6:24