Matlab and R functions for "Implementing Binomial Trees"