In scalar-oriented languages an efficient way to solve this problem can be described in 3 words: depth first search. That is:
treesum(x) is - value(x) if x is a leaf - value(x) + +/ treesum"0 (sons of x) if not The time and space should be within a small factor of the time and space to do +/\values , which none of the solutions mentioned so far comes near. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
