Here's a suggestion. 0 : 0 Ordered tree
1
/ | \
2 3 4
/ \
5 6
Corresponding binary tree
1
/
2
/ \
5 3
\ \
6 4
)
NB. Representation as subtree of complete binary tree
t=:$. 0 1 2 0 5 3 0 0 0 6 0 4 0 0 0 0
left=:+:
right=:>:@+:
parent=:<[EMAIL PROTECTED]:
depth=:<.@(2&^.)
path=:parent^:(>:@[EMAIL PROTECTED])
9 { t
6
0 $, t{~ path 9
5 2 1
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
