Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Traversing a binomial tree help
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Traversing a binomial tree help
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01097850
Message ID:
01097850
Views:
67
Hi All,

I have a binomial tree structure. I want to get all the possible paths in this tree, I have been searching for an elegant way to do this. I'll explain with an example:

A person starts with disability state 0, the following year he can get disabled and reaches state 1 or he stays active in the same state 0 (so there are two states in year 1 (2^time)). The following year 2 he can get disabled for the first time 0->1, or he stays active 0->0, or he gets better 1->0, or he disables more 1->2 (so 2^2 possibilities). And so on....

I want to make a function that returns a array of strings of all possible paths given a specific duration, so :
for year 0 : "0"
for year 1:  "01"
          :  "00"
for year 2:  "000"
             "001"
             "012"
             "010"
for year n: 2^n possibilities
I have been trying to make a readable code for this, but with no success. Any ideas?

Thanks beforehand.
Zakaria al Azhar
My blog on Actuaris.net
Next
Reply
Map
View

Click here to load this message in the networking platform